@@ -17,7 +17,7 @@ Everything in python is an object:
1717
1818First of all let's understand functions in python:
1919
20- ::
20+ .. code :: python
2121
2222 def hi (name = " yasoob" ):
2323 return " hi " + name
@@ -48,7 +48,7 @@ So those are the basics when it comes to functions. Lets take your
4848knowledge one step further. In Python we can define functions inside
4949other functions:
5050
51- ::
51+ .. code :: python
5252
5353 def hi (name = " yasoob" ):
5454 print " now you are inside the hi() function"
@@ -86,7 +86,7 @@ Returning functions from within functions:
8686It is not necessary to execute a function within another function, we
8787can return it as an output as well:
8888
89- ::
89+ .. code :: python
9090
9191 def hi (name = " yasoob" ):
9292 def greet ():
@@ -125,7 +125,7 @@ function will be returned. We can also do print ``hi()()`` which outputs
125125Giving a function as an argument to another function:
126126^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
127127
128- ::
128+ .. code :: python
129129
130130 def hi ():
131131 return " hi yasoob!"
@@ -147,7 +147,7 @@ Writing your first decorator:
147147In the last example we actually made a decorator! Lets modify the
148148previous decorator and make a little bit more usable program:
149149
150- ::
150+ .. code :: python
151151
152152 def a_new_decorator (a_func ):
153153
@@ -181,7 +181,7 @@ wondering that we did not use the @ anywhere in our code? That is just a
181181short way of making up a decorated function. Here is how we could have
182182run the previous code sample using @.
183183
184- ::
184+ .. code :: python
185185
186186 @a_new_decorator
187187 def a_function_requiring_decoration ():
@@ -200,7 +200,7 @@ run the previous code sample using @.
200200 I hope you now have a basic understanding of how decorators work in
201201Python. Now there is one problem with our code. If we run:
202202
203- ::
203+ .. code :: python
204204
205205 print (a_function_requiring_decoration.__name__ )
206206 # Output: wrapTheFunction
@@ -212,7 +212,7 @@ Luckily Python provides us a simple function to solve this problem and
212212that is ``functools.wraps ``. Let's modify our previous example to use
213213``functools.wraps ``:
214214
215- ::
215+ .. code :: python
216216
217217 from functools import wraps
218218
0 commit comments