Message213869
One of the more interesting ways to use print is printing output of a generator, as print(*generator()).
But if the generator generates a typeError, you get a very unhelpful error message:
>>> #the way it works OK
>>> def f(): yield 'a'+'b'
...
>>> print(*f())
ab
>>> #Now with a type error
>>> def f(): yield 'a'+5
...
>>> print(*f())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: print() argument after * must be a sequence, not generator
The problem is twofold:
- the message is plainly wrong, since it does work with a generator
- the actual error is hidden from view |
|
Date |
User |
Action |
Args |
2014-03-17 14:17:49 | jneb | set | recipients:
+ jneb |
2014-03-17 14:17:49 | jneb | set | messageid: <1395065869.95.0.783966483031.issue20959@psf.upfronthosting.co.za> |
2014-03-17 14:17:49 | jneb | link | issue20959 messages |
2014-03-17 14:17:49 | jneb | create | |
|