What is the proper way to use **kwargs in Python to call function and get the output from script? I will like to use the script like that:
python script.py <argument> "here description"
Here my example
class Task:
pass
def __init__(self, **kwargs):
arguments = {'cre': 'create', 'inf': 'info', 'sre': 'search', 'com': 'comment'}
arguments.update(kwargs)
self.create = arguments['cre']
self.action = arguments['inf']
self.search = arguments['sre']
self.comment = arguments['com']
def create(description):
print "Task in progress -->-->"
def search(description):
print "Searching for task"
def info(description):
print "Task Info"
def comment(description):
print "Comment task"
if __name__=='__main__':
Task(**kwargs)
On current script i get:
Traceback (most recent call last):
File "simple_function.py", line 39, in <module>
Task(**kwargs)
NameError: name 'kwargs' is not defined