Why this technology is relevant and what the scope.
Python is a general-purpose and high-level programming language. You can use Python for developing desktop GUI applications, websites, and web applications. Also, Python, as a high-level programming language, allows you to focus on the core functionality of the application by taking care of common programming tasks
After following this resource what you will learn.
Summary of what learn to get started.
Details about the technology and learning materials.
lambda
*lambda arguments: expression*
The expression is executed and the result is returned:
x = lambda a : a + 10
print(x(5))
#15
Decorators are very powerful and useful tool in Python since it allows programmers to modify the behaviour of function or class. Decorators allow us to wrap another function in order to extend the behavior of wrapped function, without permanently modifying it.
<aside> 💡 In Decorators, functions are taken as the argument into another function and then called inside the wrapper function.
</aside>
@gfg_decorator
def hello_decorator():
print("Gfg")
'''Above code is equivalent to -
def hello_decorator():
print("Gfg")
hello_decorator = gfg_decorator(hello_decorator)'''
In the above code, gfg_decorator is a callable function, will add some code on the top of some another callable function, hello_decorator function and return the wrapper function.
from flask import Flask
app = Flask(__name__)
@app.route('/')
def helloworld():
return "hello world"
if __name__ == "__main__":
app.run()
from flask import Flask
app = Flask(__name__)
The Flask constructor take name of the module as parameter.
@app.route('/')
The route function of the Flask class is a decorator which tells the application, which URL should call the associated function.
The function associated with the above route will be called by
http://192.168.0.192:5000/
@app.route('/hello')
This one by
http://192.168.0.192:5000/hello
@app.route('/')
def helloworld():
return "hello world"
The function helloworld()
is bounded by the URL /
So when the home page of the web browser is loaded, the output of helloworld()
will be rendered.
if __name__ == "__main__":
app.run()
Finally the run()
method will run the web app in local development server.
<aside> 👶 Level: Advanced
</aside>
<aside> 💼 Career Path: ‣
</aside>
Automate the Boring Stuff with Python
Free Python Tutorial - Introduction To Python Programming
TinkerHub Foundation - Creating talents with emerging technology skills
Navneet K T
Gopi Krishnan