Some code snippets for common tasks

Get the username of the active account logged in:

import getpass
currentUser = getpass.getuser()
print currentUser
'chris'

Get information about the operating system:

import platform
print platform.system()
'Windows'

print platform.release()
'XP'

print platform.version()
'5.1.2600'

Create a folder with error checking:

import os
try:
	os.makedirs('c:/test')
except Exception as err:
	print err

Check if a file or folder exists:

import os
print os.path.exists("C:/test/")
'False'