Message213869
| Author |
jneb |
| Recipients |
jneb |
| Date |
2014年03月17日.14:17:49 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1395065869.95.0.783966483031.issue20959@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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 |
|
History
|
|---|
| 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 |
|