- In python, function is the first-class object. It's can be used as an argument.
- Function can be used as a return value.
return func1: reference tofunc1.return func1(): results of evaluatingfunc().
- Should we check the argument/input?: No! The responsibility is on the caller! Your function should be well-documented, that's it! (ref)
If a function doesn't return any value, it returns
None.The
*args will give you all function parameters as a tuple: (ref)If you wanna use "keywords arguments", use
**args:Use a dictionary as an input,
Coupling
rargs, *args and **kwargs:- Required positional arguments:
rarg1,rarg2, ...
- Optional positional arguments:
args.
- Optional key-values arguments:
*kwargs.
All arguments after
* must be key-value arguments,It's convenient but don't use it regularly, use
def (in 1 line) instead.Something like that,
You can check other exceptions here.
In a class (note that, there is no
self parameter in _deco),