New submission from Jurjen N.E. Bos: 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 ---------- components: IO messages: 213869 nosy: jneb priority: normal severity: normal status: open title: print gives wrong error when printing *generator type: behavior versions: Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20959> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com