[Edu-sig] Consistency question
Kirby Urner
urnerk at qwest.net
Thu Sep 25 01:19:12 EDT 2003
> > So I'm wondering how one gets a handle on int-the-builtin-function
> > versus int the integer type (is there such?).
>
> No, there isn't.
>
Ah, I see.
> The constructor of the int type (actually int.__new__) is what does
> all the magic. __new__ methods can return whatever they please:
> int("100000000000000000000") returns a long.
>
> --Guido van Rossum (home page: http://www.python.org/~guido/)
So it seems that the int type almost doesn't need an __int__ method, since
so much power resides in the constructor.
If I subclass int and define __int__ myself, I wonder under what
circumstances __int__ will be invoked -- other than by invoking it
explicitly using myobj.__int__() semantics.
Kirby
More information about the Edu-sig
mailing list