Skip to content

Commit

Permalink
Merge pull request #27 from StevenMaude/tidy-classes
Browse files Browse the repository at this point in the history
Tidy up classes.rst
  • Loading branch information
yasoob committed Aug 18, 2015
2 parents 551d947 + b21aa27 commit 4d5c2e0
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ going!
1. Instance & Class variables
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Most beginners and even some advance Python programmers do not
Most beginners and even some advanced Python programmers do not
understand the distinction between instance and class variables. Their
lack of understanding forces them to use these different types of
variables incorrectly. Let's understand them.
Expand Down Expand Up @@ -53,7 +53,7 @@ Let's take a look at an example:
b.pi
# Output: 50
There are not much issues while using mutable class variables. This is
There are not many issues while using mutable class variables. This is
the major reason due to which beginners do not try to learn more about
this subject because everything works! If you also believe that instance
and class variables can not cause any problem if used incorrectly then
Expand Down Expand Up @@ -86,11 +86,11 @@ check the next example.
# Output: ['fly']
That is the beauty of the wrong usage of mutable class variables. To
make your code safe against this kind of surprize attacks then make sure
make your code safe against this kind of surprise attacks then make sure
that you do not use mutable class variables. You may use them only if
you know what you are doing.

2.New style classes:
2. New style classes
^^^^^^^^^^^^^^^^^^^^

New style classes were introduced in Python 2.1 but a lot of people do
Expand Down Expand Up @@ -130,16 +130,17 @@ classes.
whether you subclass from ``object`` or not. However it is recommended
that you still subclass from ``object``.

3.Magic Methods:
3. Magic Methods
^^^^^^^^^^^^^^^^

Python's classes are famous for their magic methods, commonly called
**dunder** methods. I am going to discuss a few of them.
**dunder** (double underscore) methods. I am going to discuss a few of
them.

- ``__init__``

It is a class innitializer. Whenever an instance of a class is created
it's ``__init__`` method. For instance:
It is a class initializer. Whenever an instance of a class is created
its ``__init__`` method is called. For example:

.. code:: python
Expand Down

0 comments on commit 4d5c2e0

Please sign in to comment.