Python Decorators - 4 - Hands On
Python / Python Classes and Objects
947
4. Decorators - 4
1. Define a decorator function italic_ tag which adds italic HTML tags <i> function. </i> to the value of another
2. Use the Test against custom input box to output the result for debugging.
3. Provide a string (refer test case sample) to display the output/error.
Given Input:
Hi Decorator
Expected Output:
Hi Decorator
Program:
import os
import sys
def bold_tag(func):
def inner(*args, **kwdargs):
return ''+func(*args, **kwdargs)+''
return inner
#Implement italic_tag below
def italic_tag(func):
def inner(*args, **kwdargs):
return ''+func(*args, **kwdargs)+''
return inner
def say(msg):
return msg
say=italic_tag(say)
'''Check the Tail section for input/output'''
if __name__ == "__main__":
with open(os.environ['OUTPUT_PATH'], 'w') as fout:
res_lst = list()
res_lst.append(say(input()))
fout.write("{}".format(*res_lst))
Output:
Hi Decorator
This Particular section is dedicated to Programs only. If you want learn more about Python. Then you can visit below links to get more depth on this subject.
# C Tutorials
# JAVA Tutorials
# HTML Tutorials
# Computer Fundamental
# Data Structure
# DBMS Tutorials
SQL
# C# Language
# R Language
# PHP
# Python
# Vue JS
Hi Decorator
Program:
import os import sys def bold_tag(func): def inner(*args, **kwdargs): return ''+func(*args, **kwdargs)+'' return inner #Implement italic_tag below def italic_tag(func): def inner(*args, **kwdargs): return ''+func(*args, **kwdargs)+'' return inner def say(msg): return msg say=italic_tag(say) '''Check the Tail section for input/output''' if __name__ == "__main__": with open(os.environ['OUTPUT_PATH'], 'w') as fout: res_lst = list() res_lst.append(say(input())) fout.write("{}".format(*res_lst))
Output:
Hi Decorator
This Particular section is dedicated to Programs only. If you want learn more about Python. Then you can visit below links to get more depth on this subject.
# C Tutorials
# JAVA Tutorials
# HTML Tutorials
# Computer Fundamental
# Data Structure
# DBMS Tutorials
SQL
# C# Language
# R Language
# PHP
# Python
# Vue JS