The int
type in python offers two attributes named numerator
and real
that have the same content as __int__()
.
A
The actual integer value is in ob_ival
. In essence, int_int
is simply taking the integer value from one int
object and wrapping it in another object.
Not sure why you can't see the properties. If I run this, they show up for me, in both 2.7 and 3.4 versions:
x = 8
dir(x)
EDIT: Too hard to explain in a comment, so adding to the answer.
You could easily subclass it like this:
class foo(int):
def __getitem__(self):
return self + 1
foo(8).__getitem__()
You could also use super
to explicitly access the int
object this way.
(You do realize that __getitem__
is for use with keyed objects [dict-like, say] and hence normally gets a second argument specifying the key, right? And int
and float
are not keyed.)