kkto at csis.hku.hk
Tue Mar 23 04:27:57 CET 2004
>>>>> "Stephen" == Stephen Horne <steve at ninereeds.fsnet.co.uk> writes:
>> The syntax can be extended, i.e. "def foo() as generator" looks to me
>> to be a lot more explicit than "def foo()" followed by having the
>> compiler search the function body for a yield statement in order to
>> decide if it's a generator.
Stephen> Good point. Though to me, it isn't that it's a pain for the
Stephen> compiler to search for the 'yield' - I don't care about the
Stephen> compilers pain. The problem is that *I* have to look for the
Stephen> yield and might not notice it.
I disagree. It's not just the compile which has to search for that yield
keyword, we human being reading other's uncommented code (or mis-commented
code) also has to do the same. It would do much good if the completely
different call convention of generator is made much more explicit in the
definition of the function.
More information about the Python-list