Generators can only yield ints?
defn noob
circularfunc at yahoo.se
Fri Aug 22 18:44:15 EDT 2008
def letters():
a = xrange(ord('a'), ord('z')+1)
B = xrange(ord('A'), ord('Z')+1)
while True:
yield chr(a)
yield chr(B)
>>> l = letters()
>>> l.next()
Traceback (most recent call last):
File "<pyshell#225>", line 1, in <module>
l.next()
File "<pyshell#223>", line 5, in letters
yield chr(a)
TypeError: an integer is required
>>>
Any way to get around this?
More information about the Python-list
mailing list