Skip to content

Instantly share code, notes, and snippets.

@phdoerfler
Last active April 23, 2021 09:36
Show Gist options
  • Save phdoerfler/a2c9d32980addcb1e3a1eab20689fe4d to your computer and use it in GitHub Desktop.
Save phdoerfler/a2c9d32980addcb1e3a1eab20689fe4d to your computer and use it in GitHub Desktop.
Python Cheat Sheet

#!/usr/bin/env python

3 please

import sys
if sys.version_info < (3, 0):
    sys.stdout.write("Sorry, written for Python 3\n")
    sys.exit(1)

String interpolation

user = 'Meep'
print(f'Hello {user})
import code; code.interact(local=locals())

Debugging

vars(object_of_your_desire)

More

Pretty Print

from pprint import pprint
pprint(vars(object_of_your_desire))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment