# Module H5G

Low-level HDF5 “`H5G`” group interface.

## Functional API

h5py.h5g.open(ObjectID loc, STRING name) → GroupID

  Open an existing HDF5 group, attached to some other group.

h5py.h5g.create(ObjectID loc, STRING name or None, PropLCID lcpl=None, PropGCID gcpl=None) → GroupID

  Create a new group, under a given parent group. If name is None, an anonymous group will be created in the file.

h5py.h5g.iterate(GroupID loc, CALLABLE func, UINT startidx=0, **kwds) → Return value from func

  Iterate a callable (function, method or callable object) over the members of a group. Your callable should have the signature:

      func(STRING name) => Result

  Returning None continues iteration; returning anything else aborts iteration and returns that value. Keywords:

  STRING obj_name (“.”)

    Iterate over this subgroup instead

h5py.h5g.get_objinfo(ObjectID obj, STRING name='.', BOOL follow_link=True) → GroupStat object

  Obtain information about a named object. If “name” is provided, “obj” is taken to be a `GroupID` object containing the target. The return value is a GroupStat object; see that class’s docstring for a description of its attributes.

  If follow_link is True (default) and the object is a symbolic link, the information returned describes its target. Otherwise the information describes the link itself.

## Info objects

class h5py.h5g.GroupStat

  Represents the H5G_stat_t structure containing group member info.

  Fields (read-only):

  - fileno: 2-tuple uniquely identifying the current file

  - objno: 2-tuple uniquely identifying this object

  - nlink: Number of hard links to this object

  - mtime: Modification time of this object

  - linklen: Length of the symbolic link name, or 0 if not a link.

  “Uniquely identifying” means unique among currently open files, not universally unique.

  - Hashable: Yes

  - Equality: Yes

## Group objects

class h5py.h5g.GroupID

  Represents an HDF5 group identifier

  Python extensions:

  __contains__

    Test for group member (“if name in grpid”)

  __iter__

    Get an iterator over member names

  __len__

    Number of members in this group; len(grpid) = N

  The attribute “links” contains a proxy object providing access to the `H5L` family of routines. See the docs for h5py.h5l.LinkProxy for more information.

  - Hashable: Yes, unless anonymous

  - Equality: True HDF5 identity unless anonymous

  get_comment(STRING name) → STRING comment

    Retrieve the comment for a group member.

  get_create_plist() → PropGCID

    Retrieve a copy of the `group creation property list` used to create this group.

  get_linkval(STRING name) → STRING link_value

    Retrieve the value (target name) of a symbolic link. Limited to 2048 characters on Windows.

  get_num_objs() → INT number_of_objects

    Get the number of objects directly attached to a given group.

  get_objname_by_idx(INT idx) → STRING

    Get the name of a group member given its zero-based index.

  get_objtype_by_idx(INT idx) → INT object_type_code

    Get the type of an object attached to a group, given its zero-based index. Possible return values are:

    - `LINK`

    - `GROUP`

    - `DATASET`

    - `TYPE`

  link(STRING current_name, STRING new_name, INT link_type=LINK_HARD, GroupID remote=None)

    Create a new hard or soft link. current_name identifies the link target (object the link will point to). The new link is identified by new_name and (optionally) another group “remote”.

    Link types are:

    `LINK_HARD`

      Hard link to existing object (default)

    `LINK_SOFT`

      Symbolic link; link target need not exist.

  move(STRING current_name, STRING new_name, GroupID remote=None)

    Relink an object. current_name identifies the object. new_name and (optionally) another group “remote” determine where it should be moved.

  set_comment(STRING name, STRING comment)

    Set the comment on a group member.

  unlink(STRING name)

    Remove a link to an object from this group.

## Module constants

### Object type codes

h5py.h5g.LINK

  Symbolic link

h5py.h5g.GROUP

  HDF5 group

h5py.h5g.DATASET

  HDF5 dataset

h5py.h5g.TYPE

  Named (file-resident) datatype

### Link type codes

h5py.h5g.LINK_HARD

h5py.h5g.LINK_SOFT