Re: Argparse, and linking to methods in Subclasses

2011-07-18 Thread Karim
Hello Michele, Your solution is great! You can combine it perhaps with the use of set_defaults() method of the argparse parser, I gave. Cheers karim On 07/18/2011 01:56 PM, Michele Simionato wrote: Here is an example by using my own library plac (http://pypi.python.org/pypi/plac): class

Re: Argparse, and linking to methods in Subclasses

2011-07-18 Thread Michele Simionato
Here is an example by using my own library plac (http://pypi.python.org/pypi/plac): class Server(): def configure_logging(self, logging_file): pass def check(self): pass def deploy(self): pass def configure(self): pass def __init__(self, hostnam

Re: Argparse, and linking to methods in Subclasses

2011-07-18 Thread Karim
with global: SERVER = None A the end of Argparse declarations: parser_check.set_defaults(action=do_the_check) parser_build.set_defaults(action=do_the_build) Then declare the action functions: def do_the_check(namespace_args): if not SERVER: SERVER = Server(namespace_arg.type_of_s