new-style class instance check

Richard Gruet rjgruet at yahoo.com
Sun Apr 11 06:42:23 EDT 2004


"Mike C. Fletcher" <mcfletch at rogers.com> wrote in message
news:mailman.518.1081644036.20120.python-list at python.org...

> I'm guessing what you're looking for is "everything that would have had
> a type InstanceType in Python 2.1 and before", but I don't have time to
> track down all the little corner cases for how to implement that, and
> I'd guess you'll find that there's better ways to accomplish what you
> want than using it anyway.  Type-class unification has forever blurred
> the line between class and type, and coding as if it hadn't is just
> going to cause pain IMO.

Right, you are perfectly right.
As Robert (Brewer) guessed, I was actually naively trying to detect whether
an object was an instance of a *user-defined* new-style class in an attempt
to find and equivalent to type(o) is InstanceType for new-style classes - so
my function could be more appropriately named e;G.
isUserDefinedNewStyleClassInstance(o).

Yes,  Type-class unification has blurred  the line between class and type
(and moreover old style classes still exist and contribute to the mess, so
that's now type-old class-new class unification that is needed ;-).

That's just that although I thought I understood  the general concept of
class/type unification, I have not contemplated all its practical
consequences. In *practice* (I mean my every day programmer's life) I am
confused by things like considering a function as a (new-style) class, even
if it makes perfect sense conceptually. I should stop trying to speak in
terms of instances, classes, methods, functions like a die-hard and be more
Zen, simply accept the new (Python) reality as it is. But the fact is, *I*
am now more often puzzled with the new system than I was in the past, I
spend more time wondering what things may mean. Even if my Python code
doesn't seem to break most of the time (meaning that metaphysical questions
don't concern most of coding), my brain has backwards compatibility problems
with these subtle changes.
I guess I'm like dinosaurs and doomed to disappear soon...

A depressed Richard.





More information about the Python-list mailing list