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 1275
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...@america n.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.Typ eError'>
Earlier versions:
pyTypeError
<class exceptions.Type Error 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 code?
many thx!
|
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 have run into is that the emitted html at the end of the
process is slightly different and doesn't work.
Please don't be put off by all the source code. All the guts are in this
first base class, and it doesn't do much. The rest is trivial...
|
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 declared an array as:
char *stringArray = {"one","two","three","a"};
When I pass the array using:
| |
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 (e.g. Resharper) obviously do this internally, but I can't
seem to find any that expose this simple functionality. Command line
would be fine -- in fact I'd prefer that but its not necessary.
|
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 want to call out a .js file from inside a web page to write some stuff. I've done it before, but it's been a while. I've got it ultra-simplified just to try to get it to work. (Once I've got the bugs out, I'm going to put some real code in the .js...
|
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:
_________________________________________________________________
/* Simple Thread Object
______________________________________________________________*/
#include <pthread.h>
extern "C" void* thread_entry(void*);
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |