Python cheatsheet

Read input from user

In [1]: s = raw_input('--> ') # Python 2
s = input('--> ') #Python 3

Obtain base directory from within current module

print os.path.dirname(os.path.abspath(__file__))

Note that __file__ is the pathname of the file from which the module was loaded, if it was loaded from a file.