Skip to content

Commit fabea4b

Browse files
committed
Merge pull request yasoob#45 from kingosticks/master
Some wording alterations and and typo fixes.
2 parents 372b4ac + edf3a48 commit fabea4b

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

decorators.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Decorators
22
----------
33

4-
Decorators are a significant part of Python. In simple words they are
4+
Decorators are a significant part of Python. In simple words: they are
55
functions which modify the functionality of another function. They help
66
to make our code shorter and more Pythonic. Most of the beginners do not
77
know where to use them so I am going to share some areas where
8-
decorators can make your code concise.
8+
decorators can make your code more concise.
99

1010
First, let's discuss how to write your own decorator.
1111

@@ -44,7 +44,7 @@ First of all let's understand functions in python:
4444
Defining functions within functions:
4545
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4646

47-
So those are the basics when it comes to functions. Lets take your
47+
So those are the basics when it comes to functions. Let's take your
4848
knowledge one step further. In Python we can define functions inside
4949
other functions:
5050

@@ -77,8 +77,8 @@ other functions:
7777
#outputs: NameError: name 'greet' is not defined
7878
7979
So now we know that we can define functions in other functions. In
80-
simpler words we can make nested functions. Now you need to learn one
81-
more thing that functions can return functions too.
80+
other words: we can make nested functions. Now you need to learn one
81+
more thing, that functions can return functions too.
8282

8383
Returning functions from within functions:
8484
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -112,13 +112,13 @@ can return it as an output as well:
112112
113113
Just take a look at the code again. In the ``if/else`` clause we are
114114
returning ``greet`` and ``welcome``, not ``greet()`` and ``welcome()``.
115-
Why is that? It is so because when you put parentheses around it the
116-
function gets executed whereas if you don't put parenthesis around it
115+
Why is that? It's because when you put a pair of parentheses after it, the
116+
function gets executed; whereas if you don't put parenthesis after it,
117117
then it can be passed around and can be assigned to other variables
118-
without executing it. Did you get it ? Let me explain it a little bit in
118+
without executing it. Did you get it? Let me explain it in a little bit
119119
more detail. When we write ``a = hi()``, ``hi()`` gets executed and
120-
because the name is yasoob by default, the function greet is returned.
121-
If we change the statement to ``a = hi(name = "ali")`` then the welcome
120+
because the name is yasoob by default, the function ``greet`` is returned.
121+
If we change the statement to ``a = hi(name = "ali")`` then the ``welcome``
122122
function will be returned. We can also do print ``hi()()`` which outputs
123123
*now you are in the greet() function*.
124124

@@ -144,7 +144,7 @@ are. Decorators let you execute code before and after a function.
144144
Writing your first decorator:
145145
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
146146

147-
In the last example we actually made a decorator! Lets modify the
147+
In the last example we actually made a decorator! Let's modify the
148148
previous decorator and make a little bit more usable program:
149149

150150
.. code:: python

0 commit comments

Comments
 (0)