diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index ef80808a1a4d5e..245d9f2ac104b2 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -1955,6 +1955,23 @@ updates:: # Depends on the station_id, date, and units. +.. _faq-int-type: + +I get an error when I use SomeInteger.__class__ +----------------------------------------------- + +Each value is an object and has a class called as type associated with it. +It is stored as ``object.__class__``. + +It is important to take care of how to use integer literals to view its class. +Integer literals must be parenthesized or spaced before ``.name`` attribute +access because ``.name`` is parsed as ``(.)name``. + +The tokenizer sees the '.' as making the token a float, and +``5.__class__`` is not a valid float token. You can either use it as +``(5).__class__`` or as ``5 .__class__``. + + Modules ======= diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst index 0d780e3ba89643..6a54c161ffa51c 100644 --- a/Doc/tutorial/classes.rst +++ b/Doc/tutorial/classes.rst @@ -564,6 +564,7 @@ reasons why a method would want to reference its own class. 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: