We know that everything is an object in Python and so that includes integers. So doing dir(34)
is no surprise, there are attributes available.
My confusion stems from the following, why is it that doing 34.__class__
gives a syntax error when I know that 34
does have the attribute __class__
. Furthermore, why does binding an integer to a name, say x
, and then doing x.__class__
yield my expected answer of type int?