@@ -4,28 +4,41 @@ Exploring Python
44Whether you use :ref: `idle ` or the :ref: `interactive_shell `, there are some
55useful functions to explore Python.
66
7+ .. code-block :: pycon
8+
9+ >>> x = 4.2
10+
11+ ``type() ``
12+ ----------
13+
14+ With :py:func: `type `, you can display the object type, for example:
15+
16+ .. code-block :: pycon
17+
18+ >>> type(x)
19+ <class 'float'>
20+
721 .. _help :
822
923``help() ``
1024----------
1125
12- `` help() `` has two different modes. When you type `` help() `` , you call the help
13- system, which you can use to get information about modules, keywords, and other
14- topics. When you are in the help system, you will see a prompt with `` help> ``.
15- You can now enter a module name, for example ``float ``, to search the ` Python
16- documentation <https://docs.python.org/> `_ for that type.
26+ :py:func: ` help ` has two different modes. When you type :func: ` help ` , you call
27+ the help system, which you can use to get information about modules, keywords,
28+ and other topics. When you are in the help system, you will see a prompt with
29+ `` help> ``. You can now enter a module name, for example ``float ``, to search the
30+ ` Python documentation <https://docs.python.org/ >`_ for that type.
1731
18- `` help() ` ` is part of the :doc: `pydoc <python3:library/pydoc >` library, which
32+ :func: ` help ` is part of the :doc: `pydoc <python3:library/pydoc >` library, which
1933provides access to the documentation built into Python libraries. Since every
2034Python installation comes with full documentation, you have all the
2135documentation at your fingertips even offline.
2236
23- Alternatively, you can use `` help() ` ` more specifically by passing a type or
37+ Alternatively, you can use :func: ` help ` more specifically by passing a type or
2438variable name as a parameter, for example:
2539
2640.. code-block :: pycon
2741
28- >>> x = 4.2
2942 >>> help(x)
3043 Help on float object:
3144
@@ -39,14 +52,27 @@ variable name as a parameter, for example:
3952 | __abs__(self, /)
4053 | abs(self)
4154 ...
55+ | is_integer(self, /)
56+ | Return True if the float is an integer.
57+ ...
4258
4359 For example, you will learn that ``x `` is of type ``float `` and has a function
44- :func: `__add__ ` that you can use with dot notation:
60+ :func: `is_integer ` that you can use with dot notation:
61+
62+ .. code-block :: pycon
63+
64+ >>> x.is_integer()
65+ False
66+
67+ ``id() ``
68+ --------
69+
70+ :py:func: `id ` specifies the identification number of an object, for example:
4571
4672.. code-block :: pycon
4773
48- >>> x.__add__(1 )
49- 5.2
74+ >>> id(x )
75+ 4304262800
5076
5177 ``dir() ``
5278---------
0 commit comments