simple try/except question

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Oct 29 12:03:38 EDT 2007


On 29 oct, 12:46, Alan Isaac <ais... at american.edu> wrote:

> Is the behavior below expected?
> If so, why is the exception not caught?
> Thanks,
> Alan Isaac
>
> >>> x,y='',''
> >>> try: x/y
>
> ... except TypeError: print 'oops'
> ...
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: unsupported operand type(s) for /: 'str' and 'str'

It works for me, using 2.5.1 and 2.4.3 on Windows XP.
Perhaps you reassigned TypeError?
Python 2.5 says:

py> TypeError
<type 'exceptions.TypeError'>

Earlier versions:
py> TypeError
<class exceptions.TypeError at 0x009B4570>

--
Gabriel Genellina




More information about the Python-list mailing list