Skip to content

Instantly share code, notes, and snippets.

@themoah
Last active September 6, 2017 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save themoah/c8ecf46ba015f486950dc51e4f09c1df to your computer and use it in GitHub Desktop.
Save themoah/c8ecf46ba015f486950dc51e4f09c1df to your computer and use it in GitHub Desktop.
python3 gist
if __name__ == '__main__':
main(sys.argv[1]) # The 0th arg is the module filename
if __name__ == '__main__':
unittest.main()
#!/usr/bin/env python3
Use __name__ to determine how the module is being used
If __name__ == "__main__" the module is being executed Module code is executed exactly once, on rst import
def is a statement which binds a function de nition to a name
Command line arguments are accessible through sys.argv
The script lename is in sys.argv[0]
Tuple - immutable sequance.
t = ("Norway" , 4.95, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment