![]() |
![]() |
![]() |
Ed Rogers |
David Hoese |
Josh Karpel |
MadPy is a community group and open to all experience levels. We are committed to a safe, professional environment
We are enthusiastically focused on improving our event and making it a place that is welcoming to all. All reports will be taken seriously, handled respectfully, and dealt with in a timely manner.
Learn more about the MadPy Code of Conduct:
https://github.com/madison-python/code-of-conduct
def some_things():
yield 1
yield 2
yield 3def them():
for thing in some_things():
yield thingWhat happens when we call list(them())?
list(them())[1, 2, 3]
def some_things_as_a_list():
return list(some_things())def them():
return some_things_as_a_list() # Using return
# instead of the yield call
for thing in some_things():
yield thingWhat will list(them()) return?
list(them())[]
def them():
return some_things_as_a_list()
# for thing in some_things():
# yield thinglist(them())[1, 2, 3]
Because yield appears in the function body, Python compiles them as a generator function — at compile time, before any code runs.
Calling them() returns a generator object without executing anything. The return value is silently ignored during iteration.
![]() | madpy.com |
![]() | meetup.com/madpython |
![]() | github.com/madison-python |
![]() | fosstodon.org/@madpy |
![]() | slack.madpy.com |
![]() | linkedin.com/company/madpy |









