Skip to content

Instantly share code, notes, and snippets.

@idank
Created March 18, 2015 14:28
Show Gist options
  • Save idank/364ccc16da98a4d94132 to your computer and use it in GitHub Desktop.
Save idank/364ccc16da98a4d94132 to your computer and use it in GitHub Desktop.
# BAD, not backward compatiable
def decode_message(msg):
arg1 = msg['arg1']
..
argn = msg['argn']
do_work(arg1, .., argn)
# OK
def decode_message(msg):
# arg1 might be deleted, or not exist at all
arg1 = msg.get('arg1', <some-sensible-default>)
..
do_work(arg1, ..)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment