In Python, the os.getgid() method is used to extract the real group id of the current thread. It is also used to set the groupID of the current process.
Note: The
OSmodule in Python provides an interface to deal with services related to the operating system.
os.getgid()
This method does not take any argument value.
It returns an integer value as a groupID.
# Program to generate random numbersimport randomimport os# setting random idos.setgid(random.randint(10,100))# getting current group process idgroupID = os.getgid()# Printing group idprint(groupID)
setgid() function to set current process groupID with a random value between 10 and 100.groupID of the current value.groupID of the current process.