Python os.initgroups() Method
Example
Print the group access list:
#Import os Library
import os
#get the current group id
gid = os.getgid()
#initialize the group access list for username "test" and current group id
os.initgroups("test", gid)
#Print the list
print (os.getgroups())
Definition and Usage
TThe os.initgroups() method initializes a group
access list showing all the member groups of a user plus the group id.
Note: Only available on UNIX platforms.
Syntax
os.initgroups(username, gid)
| Parameter | Description |
|---|---|
| username | Required. Specifies the username to use |
| gid | Required. Specifies the group id to use |
Technical Details
| Return Value: | None |
|---|---|
| Python Version: | 3.2 |