Why not 3.__class__ ?

Tim Peters tim.one at home.com
Thu Oct 11 17:04:22 EDT 2001


[Guido]
> I find the ''.__class__ form butt-ugly,

[James_Althoff at i2.com]
> Me too.  But then, I'm not the one that designed the double-double
> underscore stuff to begin with <wink>.

They're supposed to be ugly:  if you find yourself using __xxx__ thingies a
lot, it's supposed to be a clue that you're not using the language as
intended.

> And I don't find these "butt-ugly"
>
> x.class()
> 0.class()
> ''.class()
> [].class()
> {}.class()
>
> or
> x.getClass()
> 0.getClass()
> . . .
>
> or
> x.get_class()
> 0.get_class()
> . . .
>
> but maybe that's just me.

No, but it *is* the part of your brain hardwired to Smalltalk that avoids
functions as if they were somehow inscrutable <wink>.  The alternative
type(0), type([]), type('') etc are the intended ways to find the type of an
object.  More unfortunately than not, all classes in 2.1 had the same type,
as did all class instances.  "Healing the type/class split" is what 2.2
starts to take seriously, although isinstance(x, type(0)) was forced into
working several releases ago.

we-don't-need-20-was-to-answer-a-question-that-should-rarely-be-asked-ly
    y'rs  - tim





More information about the Python-list mailing list