Feb-25-2018, 03:30 PM
If a function is supposed to receive a parameter other than None, but for whatever reason the value of the parameter is None, this decorator will inhibit the function from executing. Very useful when required command line arguments are missing. Don't forget to import sys!
Here's the decorator:
Here's the decorator:
def none_decorator(func): def none_deco(*args): if len(sys.argv) > 1: return func(*args) return none_decoAnd a potential application:
@none_decorator def some_function(some_non_none_parameter): #put some code here