|
9 | 9 | 1. Instance & Class variables |
10 | 10 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
11 | 11 |
|
12 | | -Most beginners and even some advance Python programmers do not |
| 12 | +Most beginners and even some advanced Python programmers do not |
13 | 13 | understand the distinction between instance and class variables. Their |
14 | 14 | lack of understanding forces them to use these different types of |
15 | 15 | variables incorrectly. Let's understand them. |
@@ -53,7 +53,7 @@ Let's take a look at an example: |
53 | 53 | b.pi |
54 | 54 | # Output: 50 |
55 | 55 |
|
56 | | -There are not much issues while using mutable class variables. This is |
| 56 | +There are not many issues while using mutable class variables. This is |
57 | 57 | the major reason due to which beginners do not try to learn more about |
58 | 58 | this subject because everything works! If you also believe that instance |
59 | 59 | and class variables can not cause any problem if used incorrectly then |
@@ -86,11 +86,11 @@ check the next example. |
86 | 86 | # Output: ['fly'] |
87 | 87 |
|
88 | 88 | That is the beauty of the wrong usage of mutable class variables. To |
89 | | -make your code safe against this kind of surprize attacks then make sure |
| 89 | +make your code safe against this kind of surprise attacks then make sure |
90 | 90 | that you do not use mutable class variables. You may use them only if |
91 | 91 | you know what you are doing. |
92 | 92 |
|
93 | | -2.New style classes: |
| 93 | +2. New style classes |
94 | 94 | ^^^^^^^^^^^^^^^^^^^^ |
95 | 95 |
|
96 | 96 | New style classes were introduced in Python 2.1 but a lot of people do |
@@ -130,16 +130,17 @@ classes. |
130 | 130 | whether you subclass from ``object`` or not. However it is recommended |
131 | 131 | that you still subclass from ``object``. |
132 | 132 |
|
133 | | -3.Magic Methods: |
| 133 | +3. Magic Methods |
134 | 134 | ^^^^^^^^^^^^^^^^ |
135 | 135 |
|
136 | 136 | Python's classes are famous for their magic methods, commonly called |
137 | | -**dunder** methods. I am going to discuss a few of them. |
| 137 | +**dunder** (double underscore) methods. I am going to discuss a few of |
| 138 | +them. |
138 | 139 |
|
139 | 140 | - ``__init__`` |
140 | 141 |
|
141 | | -It is a class innitializer. Whenever an instance of a class is created |
142 | | -it's ``__init__`` method. For instance: |
| 142 | +It is a class initializer. Whenever an instance of a class is created |
| 143 | +its ``__init__`` method is called. For example: |
143 | 144 |
|
144 | 145 | .. code:: python |
145 | 146 |
|
|
0 commit comments