Learn Python Training from the Best Tutors
Search in
You'll use a decorator when you need to change the behavior of a function without modifying the function itself. A few good examples are when you want to add logging, test performance, perform caching, verify permissions, and so on. You can also use one when you need to run the same code on multiple functions.
read lessThe use of decorators in Python when we want to add some functionality to an existing function without changing that function so we can achieve that behavior with the help decorator. decorators are implemented using the "@" symbol and are used to modify the behavior of functions or classes. Try to understand with an example there is a bakery you make cakes in that. suppose the bakery is a normal function you make the cake in that then you realized you have to decorate the cake as well. In that case don't you make a change in the existing function you use decorate function for that.
Let's say you have a bakery and you want to add a decorator to your cake class that adds an extra layer of frosting to the cake. Here's an example of how you can implement it:
read less
View 2 more Answers
Related Questions
I want to learn Python but I dont know which tool is better for the future? and i want to get a job in less time. I am a fresher, 2017 passed out.
What is a Python development, UGI, Data science and Machine learning? Do they all include Python or are they different? Which is better to learn for making a career?
Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com
Ask a QuestionRecommended Articles
Top 5 reasons why you should learn Python
Python is one of the most popular programming languages in the world. It is general-purpose, object oriented, high-level programming language used in a number of programming fields. Python is a great programming language to learn as it will introduce you to the world of programming. If you are from the technical background...
Learn Hadoop and Big Data
Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...
Make a Career as a BPO Professional
Business Process outsourcing (BPO) services can be considered as a kind of outsourcing which involves subletting of specific functions associated with any business to a third party service provider. BPO is usually administered as a cost-saving procedure for functions which an organization needs but does not rely upon to...
Why Should you Become an IT Consultant
Information technology consultancy or Information technology consulting is a specialized field in which one can set their focus on providing advisory services to business firms on finding ways to use innovations in information technology to further their business and meet the objectives of the business. Not only does...
Looking for Python Training classes?
Learn from the Best Tutors on UrbanPro
Are you a Tutor or Training Institute?
Join UrbanPro Today to find students near youThe best tutors for Python Training Classes are on UrbanPro
The best Tutors for Python Training Classes are on UrbanPro