use the 'as' syntax for exceptions which works for all versions of python >= 2.6
use python2/3 portable printing and use the portable octal notation for chmod