Skip to content

Instantly share code, notes, and snippets.

@berryp
Last active November 9, 2017 03:53
Show Gist options
  • Save berryp/b5d40fae5ff4d85e2b4e0129cabd1caa to your computer and use it in GitHub Desktop.
Save berryp/b5d40fae5ff4d85e2b4e0129cabd1caa to your computer and use it in GitHub Desktop.

Default values

if somevar is None:
    somevar = somedefaultvar

vs.

somevar = somevar if somevar else somedefaultvar

Check multiple items in list

if 'key1' in os.environ and 'key1' in somelist:
    ...

vs.

if {'key1', 'key2'} in somelist:
    ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment