My (late) beef with Simple Generator syntax (PEP 255)

Cameron Horn camhorn at mac.com
Wed Nov 13 15:37:28 EST 2002


If I want to write an empty class, I do this:
class foo:
   pass

If I want to write an empty function, I write this:
def foo():
   pass
-or-
def foo():
   return

If I want to write an empty generator, I write this(?):
def foo():
   return
   yield "never"

Assuming that having an empty generator is as valid as empty functions and classes, what kind of linguistic cruft is that?  I expect better out of python, dang it.

What I'd like to write is:
gen foo():
   return





More information about the Python-list mailing list