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' 6 1260
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'
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.
>>x,y = '','' try: x/y
.... except TypeError: print 'oops'
....
oops
-tkc
On 29 oct, 12:46, Alan Isaac <ais...@american.eduwrote:
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:
pyTypeError
<type 'exceptions.TypeError'>
Earlier versions:
pyTypeError
<class exceptions.TypeError at 0x009B4570>
--
Gabriel Genellina
Tim Chase wrote:
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
Tim Chase wrote:
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
False alarm.
Fresh start of interpreter and all is well.
Apologies.
Still tracking.
Alan
Gabriel Genellina wrote:
Perhaps you reassigned TypeError?
Yes, that was it.
Sheesh.
Thanks!
Alan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Nick Jacobson |
last post by:
Say I have a function foo that throws an IndexError exception, and I
want to handle it:
def foo(a, b, c):
print a, b, c #, etc.
def main():
#define vars
try:
foo(a, b, c)
|
by: Alan |
last post by:
hi all,
I want to define a constant length string, say 4
then in a function at some time, I want to set the string to a constant
value, say a
below is my code but it fails
what is the correct...
|
by: 42 |
last post by:
I implemented a simple class inherited from Page to create a page
template. It simply wraps some trivial html around the inherited page,
and puts the inherited page into a form.
The problem I...
|
by: main() |
last post by:
Hi all,
If 'a' is an array of ten characters , say
char a;
whenever i say 'a' in my code it means &a. (except in sizeof
operator).
Then why is &a is same as &a and not &(&a) ?
|
by: Michael |
last post by:
Hi,
I am trying to pass a function an array of strings, but I am having trouble
getting the indexing to index the strings rather than the individual
characters of one of the strings.
I have...
|
by: galiorenye |
last post by:
Hi,
Given this code:
A** ppA = new A*;
A *pA = NULL;
for(int i = 0; i < 10; ++i)
{
pA = ppA;
//do something with pA
|
by: beantaxi |
last post by:
Hello all,
I'm looking for a very simple code analysis tool. I have a large
codebase to analyze, and all I really need to do is to find all uses
of all methods in a few interfaces.
Many tools...
|
by: fussfart |
last post by:
I'm trying to do something that should be very simple but isn't working! (I also want to do something somewhat more complicated, but that has to wait until I figure out the simple stuff.)
First, I...
|
by: optimistx |
last post by:
A variable in global scope
var a1 = 'contents of global variable a1';
can be references (with some limitations) as
window; // or
window.a1; // or even
window;
|
by: Chris M. Thomasson |
last post by:
I use the following technique in all of my C++ projects; here is the example
code with error checking omitted for brevity:
_________________________________________________________________
/*...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |