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 1257
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: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |