Skip to content

Instantly share code, notes, and snippets.

@huseyinyilmaz
Created February 6, 2018 00:51
Show Gist options
  • Save huseyinyilmaz/445ecfa8edf647deaa1ec26c8190c952 to your computer and use it in GitHub Desktop.
Save huseyinyilmaz/445ecfa8edf647deaa1ec26c8190c952 to your computer and use it in GitHub Desktop.
from collections import defaultdict
def run():
print("RUNNING")
return 'val'
test = {'store':1}
print(test.get('store', run))
print(test.get('not_stored', run))
test2 = defaultdict(run)
test2['store'] = 1
print(test2['store'])
print(test2['not_stored']) # calls function
# output:
# 1
# <function run at 0x102877ae8>
# 1
# RUNNING
# val
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment