Sayth Renshaw <flebber.c...@gmail.com> writes: > This I did however I also get a list of None. I don't understand where > none comes from. Can you please clarify?
Every function in Python, if it returns, returns a value. In an expression that consists of only a function call, the expression resolves to the return value from calling that function. The ‘print’ function's return value is always None. > a = (print("Got {0}".format(num[0])) for num in enumerate(range(10))) > b = list(a) > print(b) Try this: a = (None for num in enumerate(range(10))) b = list(a) print(b) print(repr(b)) Now try this: def always_return_none(dummy): return None a = (always_return_none("Got {0}".format(num[0])) for num in enumerate(range(10))) b = list(a) print(b) print(repr(b)) Now try this: c = print("Foo") print(c) print(repr(c)) Does that help? -- \ “I knew it was a shocking thing to say, but … no-one has the | `\ right to spend their life without being offended.” —Philip | _o__) Pullman, 2010-03-28 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list