💾 Archived View for tris.fyi › pydoc › grp captured on 2022-01-08 at 13:45:45. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Back to module index

Go to module by name

grp

Access to the Unix group database.

Group entries are reported as 4-tuples containing the following fields
from the group database, in order:

  gr_name   - name of the group
  gr_passwd - group password (encrypted); often empty
  gr_gid    - numeric ID of the group
  gr_mem    - list of members

The gid is an integer, name and password are strings.  (Note that most
users are not explicitly listed as members of the groups they are in
according to the password database.  Check both databases to get
complete membership information.)

Classes

struct_group

grp.struct_group: Results from getgr*() routines.

This object may be accessed either as a tuple of
  (gr_name,gr_passwd,gr_gid,gr_mem)
or via the object attributes as named in the above tuple.

count(self, value, /)

  Return number of occurrences of value.
index(self, value, start=0, stop=9223372036854775807, /)

  Return first index of value.

  Raises ValueError if the value is not present.
gr_gid = <member 'gr_gid' of 'grp.struct_group' objects>
  group id
gr_mem = <member 'gr_mem' of 'grp.struct_group' objects>
  group members
gr_name = <member 'gr_name' of 'grp.struct_group' objects>
  group name
gr_passwd = <member 'gr_passwd' of 'grp.struct_group' objects>
  password
n_fields = 4
n_sequence_fields = 4
n_unnamed_fields = 0

Functions

getgrall

getgrall()

  Return a list of all available group entries, in arbitrary order.

  An entry whose name starts with '+' or '-' represents an instruction
  to use YP/NIS and may not be accessible via getgrnam or getgrgid.

getgrgid

getgrgid(id)

  Return the group database entry for the given numeric group ID.

  If id is not valid, raise KeyError.

getgrnam

getgrnam(name)

  Return the group database entry for the given group name.

  If name is not valid, raise KeyError.