I have the following structure in my code:
#!/usr/bin/env python
import <something>
.
.
.
from modules import *
from optparse import OptionParser
class Main:
def __init__(self):
parser = self.get_argument()
self.set_argument(parser)
def my_args(self):
parser = OptionParser(usage='usage: %prog [options]', version='%prog 1.0.0')
parser.add_option('-t', '--test', action='store_true', dest='test', default=False,
help='Help of test.')
.
.
.
return parser
def set_args(self, parser)
options, args = parser.parse_args()
params = dict(test=options.test, ..., arg100=options.arg100)
self.start(**params)
def start(self, **params):
print params
def ...:
...
.
.
.
if __name__ == '__main__':
Main()
I want to run start for getting parameters and its values for using in other functions. but:
TypeError: start() takes exactly 2 arguments (1 given)
How can I use kwargs for passing them?
What is best way in order to use parameters in start.
I am really new with kwargs.
start()method? If I use thestart()method you've written above, it doesn't error, just prints out an empty dictionary.testdeclared somewhere. You might want to fix those problems.