Is there a standard module library function to access /etc/passwd or /etc/group

Robin Cull robin.cull at
Wed Jul 30 14:16:43 CEST 2003

Hi all, 

I'm writing a script that needs to do lookups on the UNIX passwd and
groups file on textual usernames/group names and return numeric
UID/GID.  Something that gives access to the C standard libarary
functions get[pw|group]ent(), for example.  I've Googled around on
various logical search terms and looked through pydoc and the module
reference but haven't found anything up to this point.  I'd have
thought that the os module would provide this sort of access.  I did
find something called UserDBM but this appears not to be a standard

Before I go away and write a couple of functions to do this myself,
can anyone tell me if there is a module that provides this sort of
interface?  I'd really like it to be a standard module as the script
will have to run at a lot of different sites and I'm hoping there are
no external dependencies past an RPM installation of Python.  If not,
I'll do my own local functions in the script.

Thanks all.  



More information about the Python-list mailing list