Adjusted to match PEP 8 code style and PEP 257 style doc strings
Converted print statements to use () instax instead of spaces for py3 support
Migrated from getopt to optparse