Newbie: Why doesn't this work

petr.jakes.tpc at gmail.com petr.jakes.tpc at gmail.com
Tue Jan 1 23:11:12 EST 2008


Steven,
thanks for a nice explanation.

I am trying to experiment a little bit with new-style class and I am
confused why following example always returns 0 (zero). I was
expecting <generator object> will return values from 0 to 9 and finaly
an Exception.

class GenExample(object):

    def getInfo(self):
        for no in range(10):
            yield no

    myNo=property(getInfo)

gen=GenExample()
print gen.myNo.next()
print gen.myNo.next()
.
.
print gen.myNo.next()

--
Petr Jakes



More information about the Python-list mailing list