generator exceptions

Michael Palmer m_palmer45 at yahoo.ca
Fri Sep 19 10:21:42 EDT 2008


On Sep 19, 9:40 am, Alexandru  Mosoi <brtz... at gmail.com> wrote:
> i have a generator that raises an exception when calling next(),
> however if I try to catch the exception and print the traceback i get
> only the line where next() was called
>
> while True:
>   try:
>     iterator.next()
>   except StopIteration:
>     break
>   except Exception, e:
>     traceback.print_exc()
>
> how do I get the traceback starting from where exception was raised in
> first place?

What happens if you simply remove the 'except Exception' clause? It
should print the entire traceback by default.



More information about the Python-list mailing list