My (late) beef with Simple Generator syntax (PEP 255)
Cameron Horn
camhorn at mac.com
Wed Nov 13 17:11:59 EST 2002
On Wednesday, Nov 13, 2002, at 01:55PM, David Eppstein <eppstein at ics.uci.edu> wrote:
>In article <3DD2C505.96B41A1C at hotmail.com>,
> Alan Kennedy <alanmk at hotmail.com> wrote:
>
>> Cameron Horn wrote:
>>
>> > If I want to write an empty generator, I write this(?):
>> > def foo():
>> > return
>> > yield "never"
>>
>> What is the semantic of "an empty generator", i.e. what does it mean? A
>> generator that never generates any values?
>
>What I wonder is, why does it need to be a generator? What's wrong with
>def foo(): return ( )
>?
You're right if it's a one-time thing. However, if I've got a scaffolding like this, then it matters.
def process_generator(function):
for x in function():
print x
More information about the Python-list
mailing list