Why not 3.__class__ ?
James_Althoff at i2.com
James_Althoff at i2.com
Thu Oct 11 16:16:42 EDT 2001
Guido van Rossum wrote:
>I find the ''.__class__ form butt-ugly,
Me too. But then, I'm not the one that designed the double-double
underscore stuff to begin with <wink>.
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.
>and would recommend type('')
>instead. Fortunately, in 2.2 there are built-in names that express
>these types much clearer:
>
>isinstance(x, str)
>isinstance(x, int)
>isinstance(x, list)
>isinstance(x, tuple)
>isinstance(x, dictionary)
That's good. There's still the slight downside that it's yet another thing
to remember or look up in a book: is it "str" or "string"?, "int" or
"integer"?, "dict" or "dictionary"?.
In any case, the new 2.2 forms appear to be the way to go.
Thanks (Tim and Guido) for the recommendation,
Jim
More information about the Python-list
mailing list