@@ -6,7 +6,7 @@ type of an object at runtime. It is one of Python's strengths.
6
6
Everything in Python is an object and we can examine those objects.
7
7
Python ships with a few built-in functions and modules to help us.
8
8
9
- 1. \ ``dir ``
9
+ ``dir ``
10
10
^^^^^^^^^^^
11
11
12
12
In this section we will learn about ``dir `` and how it facilitates us
@@ -20,21 +20,21 @@ example:
20
20
21
21
my_list = [1 , 2 , 3 ]
22
22
dir (my_list)
23
- # Output: ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',
24
- # '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__',
25
- # '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__',
26
- # '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__',
23
+ # Output: ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__',
24
+ # '__delslice__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__',
25
+ # '__getitem__', '__getslice__', '__gt__', '__hash__', '__iadd__', '__imul__',
26
+ # '__init__', '__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__',
27
27
# '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__rmul__',
28
- # '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__',
29
- # '__subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop',
28
+ # '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__',
29
+ # '__subclasshook__', 'append', 'count', 'extend', 'index', 'insert', 'pop',
30
30
# 'remove', 'reverse', 'sort']
31
31
32
32
Our introspection gave us the names of all the methods of a list. This
33
33
can be handy when you are not able to recall a method name. If we run
34
34
``dir() `` without any argument then it returns all names in the current
35
35
scope.
36
36
37
- 2. \ ``type `` and ``id ``
37
+ ``type `` and ``id ``
38
38
^^^^^^^^^^^^^^^^^^^^^^^
39
39
40
40
The ``type `` function returns the type of an object. For example:
@@ -64,7 +64,7 @@ The ``type`` function returns the type of an object. For example:
64
64
print (id (name))
65
65
# Output: 139972439030304
66
66
67
- 3. \ ``inspect `` module
67
+ ``inspect `` module
68
68
^^^^^^^^^^^^^^^^^^^^^^
69
69
70
70
The inspect module also provides several useful functions to get
0 commit comments