I have a class that derives from Exception. In Python 2.4,
isinstance(MyClass(), types.InstanceType) was True. In 2.5, it's
False.
Further experimentation showed that derivation from object was the
culprit; new-style objects are not considered "instances" in the above
sense. I wasn't able to figure out a workaround. Is there one, or is
the distinction between traditional classes and built-in types only
going to get more and more hazy? 3 1076 ee****@gmail.com wrote:
Further experimentation showed that derivation from object was the
culprit; new-style objects are not considered "instances" in the above
sense. I wasn't able to figure out a workaround. Is there one, or is
the distinction between traditional classes and built-in types only
going to get more and more hazy?
new-style classes *are* types.
one way to test for a new-style object is to compare type(obj) to
obj.__class__; if they point to the same object, it's a new-style object.
</F>
On Jan 3, 9:15*pm, "eef...@gmail.com" <eef...@gmail.comwrote:
I have a class that derives from Exception. *In Python 2.4,
isinstance(MyClass(), types.InstanceType) was True. *In 2.5, it's
False.
Further experimentation showed that derivation from object was the
culprit; new-style objects are not considered "instances" in the above
sense. *I wasn't able to figure out a workaround.
IIRC, this is because since 2.5 Exception is a new style class. New
style objects are instances of their class, not of InstanceType as was
the case with instances of old-style classes. So in your case
isinstance(MyClass(), Exception) will return True.
Is there one, or is
the distinction between traditional classes and built-in types only
going to get more and more hazy?
I'm not sure what you mean here.
--
Arnaud
Further experimentation showed that derivation from object was the
culprit; new-style objects are not considered "instances" in the above
sense. I wasn't able to figure out a workaround. Is there one, or is
the distinction between traditional classes and built-in types only
going to get more and more hazy?
In the long run (ie. Python 3), the distinction is going to be very
hazy, very dark: it will entirely disappear. There will be only one
concept of type/class, not two, so there will be no point
distinguishing between types and classes.
Regards,
Martin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Madestro |
last post by:
Hi guys,
I am making a small program to retrieve e-mails from POP accounts. I got all
the e-mail parsing stuff figured out, but I cannot seem to come up with a way
to find out which e-mails are...
|
by: Razvan |
last post by:
Hi !
Is there any difference between new X and new X() ?!
Regards,
Razvan
|
by: kUfa.scoopex |
last post by:
Hi there!
I have a small problem, and i really dont see any convenient way to fix it.
Basically, i'd like to overload global new operators, into something like
this:
void *operator new(...
|
by: Dave |
last post by:
Hello all,
I'd like to find a source on the web that discusses, in a comprehensive
manner and in one place, everything about new / delete. It should include
overloading operator new, the new...
|
by: scorpiotgs |
last post by:
I downloaded a script for a menu (below) but I want all the links i
this part(ze_menu3) to open in a new window.
this probably a noob question, but i couldnt figure it out, so pleas
help me
...
|
by: Dave Elliott |
last post by:
After inserting a new data row to a DataTable that is bound to a
datagrid, I am unable to change data in a row that is after the newly
added row without getting bizarre results.
I have added the...
|
by: Steve |
last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I
have code that sets the default value of each field to its current value. For a
new record, I can put the focus in any...
|
by: jm |
last post by:
I got the code below from the .NET SDK. I am still new to C# and I
don't understand how the code works. And by that I mean I don't
understand how the program knows to execute it. I can find no...
|
by: Mike Bulava |
last post by:
I have created a base form that I plan to use throughout my application let
call the form form1. I have Built the project then add another form that
inherits from form1, I add a few panel controls...
|
by: Grizlyk |
last post by:
Hi, people.
Can anybody explain me "multiple 'new' at single line"
behavior. Consider:
p::p(void*);
p::p(void*,void*);
new A( p(new B), p( new C(p(new D), p(new E)) ), p(new F));
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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: 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...
|
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...
|
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,...
|
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...
| | |