Last active
August 29, 2015 14:10
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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