Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 ``<literal>.name`` is parsed as ``(<literal>.)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
=======

Expand Down
1 change: 1 addition & 0 deletions Doc/tutorial/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down