On Fri, Mar 03, 2006, Pat Martin wrote: > > Hello all, > I seem to be having a problem finding the right tool in python. Given > a username I want to find the uid for it. I can do the reverse very > easily with: > pwd.getpwuid(2012) > This returns a tuple of data from the passwd file. But I want to do > something like: > command(username) > And get something that returns the uid (the number).
You're close: import pwd pw = pwd.getpwnam('username') Bill -- INTERNET: [EMAIL PROTECTED] Bill Campbell; Celestial Systems, Inc. URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way FAX: (206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676 There is no distinctly native American criminal class save Congress -- Mark Twain _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor