this looks like a bug in generator comprehension

Michele Simionato michele.simionato at gmail.com
Fri Nov 12 04:44:04 EST 2004


Consider this example:

def f(x,y):
   yield str(x) + y

"".join([s for s in f(1,2)])

I get correctly 

TypeError: cannot concatenate 'str' and 'int' objects

However if I use a generator comprehension (I am using Python 2.4b2)
I get a misleading error message:

TypeError: sequence expected, generator found

Is this a known bug?

                                Michele Simionato



More information about the Python-list mailing list