diff --git a/source_code/learning/decorator.py b/source_code/learning/decorator.py new file mode 100644 index 0000000..8ef04f3 --- /dev/null +++ b/source_code/learning/decorator.py @@ -0,0 +1,19 @@ +#!/bin/python +# +# An example of Python Decorator +# + +def pretty_sumab(func): + def inner(a,b): + print(str(a) + " + " + str(b) + " is ", end="") + return func(a,b) + + return inner + +@pretty_sumab +def sumab(a,b): + summed = a + b + print(summed) + +if __name__ == "__main__": + sumab(5,3) \ No newline at end of file