simple try/except question

A

Alan Isaac

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

Tim Chase

Is the behavior below expected?
If so, why is the exception not caught?
Thanks,
Alan Isaac

... except TypeError: print 'oops'
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for /: 'str' and 'str'

A typo in your code? It works for me(tm)...

Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more
information..... except TypeError: print 'oops'
....
oops

-tkc
 
G

Gabriel Genellina

Is the behavior below expected?
If so, why is the exception not caught?
Thanks,
Alan Isaac


... 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>
 
A

Alan Isaac

Tim said:
It works for me(tm)...
Python 2.4.3

Sorry to have left out that detail.
Yes, it works for me in Python 2.4,
but not in 2.5.1.

The code I posted was copyied from the interpreter.

Alan Isaac
 
A

Alan Isaac

False alarm.
Fresh start of interpreter and all is well.
Apologies.
Still tracking.
Alan
 
A

Alan Isaac

Tim said:
It works for me(tm)...
Python 2.4.3

Sorry to have left out that detail.
Yes, it works for me in Python 2.4,
but not in 2.5.1.

The code I posted was copyied from the interpreter.

Alan Isaac
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top