[Edu-sig] Consistency question

Guido van Rossum guido at python.org
Wed Sep 24 23:07:54 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.

> For example:
>  >>> type(__builtins__.iter)
>  <type 'builtin_function_or_method'>
>  >>> type(__builtins__.issubclass)
>  <type 'builtin_function_or_method'>
> but
>  >>> type(__builtins__.int)
>  <type 'type'>
> It would seem there'd be a builtin_function_or_method named int, in
> addition to the int type, but I can't seem to get at it using dir()
> or type().  Is there a way to bind the built-in int function to a
> name?

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/)

More information about the Edu-sig mailing list