mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	bpo-32651 Recommend getpass.getuser() (#5301)
* bpo-32651 - In the documentation for os.getlogin(), recommend getpass.getuser()
This commit is contained in:
		
							parent
							
								
									22feeb88b4
								
							
						
					
					
						commit
						d499031f5f
					
				
					 2 changed files with 11 additions and 8 deletions
				
			
		| 
						 | 
					@ -42,8 +42,10 @@ The :mod:`getpass` module provides two functions:
 | 
				
			||||||
   Return the "login name" of the user.
 | 
					   Return the "login name" of the user.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   This function checks the environment variables :envvar:`LOGNAME`,
 | 
					   This function checks the environment variables :envvar:`LOGNAME`,
 | 
				
			||||||
   :envvar:`USER`, :envvar:`LNAME` and :envvar:`USERNAME`, in order, and returns
 | 
					   :envvar:`USER`, :envvar:`LNAME` and :envvar:`USERNAME`, in order, and
 | 
				
			||||||
   the value of the first one which is set to a non-empty string.  If none are set,
 | 
					   returns the value of the first one which is set to a non-empty string.  If
 | 
				
			||||||
   the login name from the password database is returned on systems which support
 | 
					   none are set, the login name from the password database is returned on
 | 
				
			||||||
   the :mod:`pwd` module, otherwise, an exception is raised.
 | 
					   systems which support the :mod:`pwd` module, otherwise, an exception is
 | 
				
			||||||
 | 
					   raised.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   In general, this function should be preferred over :func:`os.getlogin()`.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -325,10 +325,11 @@ process and user.
 | 
				
			||||||
.. function:: getlogin()
 | 
					.. function:: getlogin()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Return the name of the user logged in on the controlling terminal of the
 | 
					   Return the name of the user logged in on the controlling terminal of the
 | 
				
			||||||
   process.  For most purposes, it is more useful to use the environment
 | 
					   process.  For most purposes, it is more useful to use
 | 
				
			||||||
   variables :envvar:`LOGNAME` or :envvar:`USERNAME` to find out who the user
 | 
					   :func:`getpass.getuser` since the latter checks the environment variables
 | 
				
			||||||
   is, or ``pwd.getpwuid(os.getuid())[0]`` to get the login name of the current
 | 
					   :envvar:`LOGNAME` or :envvar:`USERNAME` to find out who the user is, and
 | 
				
			||||||
   real user id.
 | 
					   falls back to ``pwd.getpwuid(os.getuid())[0]`` to get the login name of the
 | 
				
			||||||
 | 
					   current real user id.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   Availability: Unix, Windows.
 | 
					   Availability: Unix, Windows.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue