5 Nov 2011 How to get username, home directory, and hostname with Python import getpass username = getpass.getuser() print username. saltycrane .