[Python-3000] Fwd: proposal: disambiguating type

Chermside, Michael mchermside at ingdirect.com
Tue May 23 14:02:26 CEST 2006


Guido writes:
> Well, you could overload __class__ to "lie" -- but type won't. I'd
> rather not lost that functionality. I expect that with proxies
> becoming more popular they may start lying about __class__. For most
> purposes that's fine but I'd like to be able to tell whether I'm
> dealing with a proxy, if I really need to know.


Hmm...

There are two ways to access a piece of information. You can either use
the built-in "foo(x)" function, or you can use a special
double-underscore
"x.__foo__". One of these is spoofable by proxies, the other returns
the REAL value for those times when you really need to know.

Gee... I'd expect that "foo(x)" was the spoofable one and "x.__foo__"
the real one. Anything else sounds quite odd. Are we going to advise
users with something like this:

    Normally use the x.__foo__ property. Please try to avoid the
    simple foo(x) built-in -- it is really only for experts.

My preference would be to have "foo(x)" simply return "x.__foo__" (which
is spoofable) to encourage novices to do the right thing. Then provide
"somemodule.realfoo(x)" as the non-spoofable version for experts.

-- Michael Chermside

PS: __foo__ == __class__, foo(x) == type(x) or typeof(x), I'm not sure
  what somemodule equals.

PPS: I apologize for the silly disclaimer below.





*****************************************************************************
This email may contain confidential or privileged information. If you believe
 you have received the message in error, please notify the sender and delete 
the message without copying or disclosing it.
*****************************************************************************



More information about the Python-3000 mailing list