- Trending Categories
- Data Structure
- Operating System
- C Programming
- Environmental Science
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to make a chain of function decorators in Python?
Decorators are “wrappers”, which allow us to execute code before and after the function they decorate without modifying the function itself.
The given code can be wrapped in a chain of decorators as follows.
def makebold(fn): def wrapped(): return "" + fn() + "" return wrapped def makeitalic(fn): def wrapped(): return "" + fn() + "" return wrapped @makebold @makeitalic def hello(): return "hello world" print hello()
C:/Users/codegyan/~.py hello world
If this html code is executed as in the link given below we get the output as bold and italicised ‘hello world’.
- How to redirect HTTP to HTTPS Using htaccess
- How can we create recursive functions in Python?
- Write a ‘C’ Program to compute the sum of all elements stored in an array using pointers
- What are Python function attributes?
- What does ‘<?=’ short open tag mean in PHP ?
- How to print hello world using C Language
- How To Send mail from your Gmail account using Python
- How to Implement Stack Operations Using Array using C
- How to make a chain of function decorators in Python?
- How to calculate gross salary of a person using C Program
- Write C Program to Reversing an Array Elements in C Programming
- Write a C program using pointers to read in an array of integers and print its elements in reverse order.
- Write C program to find Exponent Power Series
- How To Clean Up Unnecessary Code From WordPress Header Without Plugins
- Recursive program to linearly search an element in a given array using C
- How to Calculate Area of Rectangle using C Program