diff -r fd53f083768c Doc/faq/programming.rst --- a/Doc/faq/programming.rst Sat Mar 08 21:40:29 2014 -0500 +++ b/Doc/faq/programming.rst Tue Mar 11 18:11:52 2014 +0100 @@ -1601,6 +1601,32 @@ 13891296 +.. _faq-int-type: + +Syntax error while calling a method on an integer value +------------------------------------------------------- + +You get a syntax error when trying to call a method on +``int`` value as follows. + + >>> 5.__class__ + File "", line 1 + 5.__class__ + ^ + SyntaxError: invalid syntax + +This is because the Python parser considers that a period written after +a number literal is a decimal point, so to turn that period into an attribute +access you have to add parentheses around the literal. In the above case, +the tokenizer sees the '.' as making the token a float, and ``5.__class__`` +is not a valid float token. + +The right way to call a method on an integer is as follows: + + >>> (5).__class__ + + + Modules ======= diff -r fd53f083768c Doc/tutorial/classes.rst --- a/Doc/tutorial/classes.rst Sat Mar 08 21:40:29 2014 -0500 +++ b/Doc/tutorial/classes.rst Tue Mar 11 18:11:52 2014 +0100 @@ -470,6 +470,7 @@ Each value is an object, and therefore has a *class* (also called its *type*). It is stored as ``object.__class__``. +See also :ref: `faq-int-type` .. _tut-inheritance: