[Python-Dev] PEP 288: Generator Attributes

Raymond Hettinger Raymond Hettinger" <python@rcn.com
Fri, 22 Nov 2002 03:46:08 -0500

PEP 288 has been updated and undeferred.
Comments are solicited.

The old proposal for generator parameter passing with g.next(val)
has been replaced with simply using attributes in about the same
way as classes:

def outputCaps(logfile):
    while True:
        line = __self__.data
        yield None
outputCaps.data = ""      # optional attribute initialization

g = outputCaps(open('logfil.txt','w'))
for line in open('myfile.txt'):
    g.data = line

The separate proposed for generator exceptions
is unmodified from before.