Define A Decorator Function Bold Tag
Generally we decorate a function and reassign it as ordinary make pretty ordinary.
Define a decorator function bold tag. A decorator is a special kind of declaration that can be attached to a class declaration method accessor property or parameter decorators use the form expression where expression must evaluate to a function that will be called at runtime with information about the decorated declaration. Decorators allow us to wrap another function in order to extend the behavior of wrapped function without permanently modifying it. Function decorators are simply wrappers to existing functions.
This sounds confusing but it s really not especially after you ve seen a few examples of how decorators work. But they are a neat way to add functionality to functions and classes. Decorators are very powerful and useful tool in python since it allows programmers to modify the behavior of function or class.
The b tag specifies bold text without any extra importance. We can use the symbol along with the name of the decorator function and place it above the definition of the function to be decorated. Tips and notes note.
In this example let s consider a function that wraps the string output of another function by p tags. Decorators can be a bit mind bending when first encountered and they can also be a bit tricky to debug. For example given the decorator sealed we might write the sealed function as follows.
Return b func args kwdargs b return inner def say msg. This is a common construct and for this reason python has a syntax to simplify this. Python decorator are the function that receive a function as an argument and return another function as return value.
Return msg say bold tag say check the tail section for input output. According to the html5 specification the b tag should be used as a last resort when no other tag is more appropriate. Define a decorator function bold tag which adds bold html tags b b to return the value of some other function mport sys import os define and implement bold tag def bold tag func.
