Roy Smith wrote:

> You can't tell the difference between:
> 
> try:
>   for i in 5:
>     print i + 1
> except TypeError:
>   print "non-iterable"
> 
> and
> 
> try:
>   for i in ["one", "two", "three"]:
>     print i + 1
> except TypeError:
>   print "can't add string and integer"


try:
     for item in obj:
         do_stuff(item)
except TypeError, msg:
     if msg == "iteration over non-sequence":
         handle_non_iterator()
     else:
         # re-raise the exception
         raise



-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to