Skip to content

Instantly share code, notes, and snippets.

@agfor
Last active August 29, 2015 14:10
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 agfor/a81e60d5ae4bd8db70ca to your computer and use it in GitHub Desktop.
Save agfor/a81e60d5ae4bd8db70ca to your computer and use it in GitHub Desktop.
Example of function returning a value or a generator, see stackoverflow.com/q/7113032/#comment42623885_7113061
>>> def foo(bar):
... if bar:
... def baz():
... yield True
... return baz()
... else:
... return False
...
>>> foo(True)
<generator object baz at 0x100b82910>
>>> foo(False)
False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment