type() new style class instance says "class", not "ObjectType"

Brad Clements bkc at Murkworks.com
Thu Apr 11 12:50:02 EDT 2002


Heh.  3 posts lambasting me for using type(), and none of them actually
answered my question. ;-)

The point of my post is: why does type(newstyleinstance) return <class
__main__.x> rather than something like <instance __main__.x>?

---

aaaanyway.. "type(thing) in [InstanceType]" is what xml_pickle uses to
figure out how to pickle stuff.

Since xml_pickle dies trying to pickle instances of new style classes, I
went through and added isinstance(thing,ObjectType) which seems to work.

However you also say its wrong, which I agree is the wrong solution.

I just want to be able to xml_pickle any Python object. I don't write this
code, I just use it!

So what's needed is a reliable mechanism for determining that "something" is
an instance of a class. But in 2.2, looks like everything is an instance.
Fortunately I can just wait for someone smarter than I am to solve this
problem.

--
Novell DeveloperNet Sysop #5

_
"Alex Martelli" <aleax at aleax.it> wrote in message
news:kZbt8.5601$b62.137821 at news1.tin.it...
> Brad Clements wrote:
>
> > Could someone explain this to me.
> >
> > Lots of code does  type(x) in [InstanceType]
>
> I'll explain to you why lots of code does typetesting if you explain to me
> lemmings' alleged propensity for hurling themselves off a cliff.  You go
> first -- I suspect I can then just copy and paste your explanation right
> back to you:-).
>
>
> Alex
>




-----=  Posted via Newsfeeds.Com, Uncensored Usenet News  =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
 Check out our new Unlimited Server. No Download or Time Limits!
-----==  Over 80,000 Newsgroups - 19 Different Servers!  ==-----



More information about the Python-list mailing list