A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/1999-December/001560.html below:

[Python-Dev] Missing POSIX functions: the list

[Python-Dev] Missing POSIX functions: the list [Python-Dev] Missing POSIX functions: the listGuido van Rossum guido@CNRI.Reston.VA.US
Thu, 09 Dec 1999 12:16:03 -0500
> > getlogin() -- returns user's login name
> > 	 -- could do something similar with pwd.getpwuid( os.getuid() )[0], but
> > 	 getlogin() apparently looks in utmp
> 
> With a documentation proviso that utmp is very old-fashioned, and you
> really should do the getuid() thing unless you definitely want to get
> the login ID from utmp.  Perhaps an alternate "getlogin" (different
> name?) that does the getuid() thing could be provided.

There's the getpass module which has a getuser() function that looks
in various env vars and if all else fails uses getuid() and pwd.

If the goal is to get the user ID without being fooled, using
os.getuid() or os.geteuid() directly seems to be the right thing to
do; I don't see the need for a shorthand for
pwd.getpwuid(os.getuid())[0] (which is what getuser() uses).

--Guido van Rossum (home page: http://www.python.org/~guido/)



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4