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 Server():
def configure_logging(self, logging_file):
pass
def check(self):
pass
def deploy(self):
pass
def configure(self):
pass
def __init__(self, hostname):
self.hostname = hostname
class SpamServer(Server):
def check(self):
pass
class HamServer(Server):
def deploy(self):
pass
def main(classname, hostname, methname): # add error checking at will
instance = globals()[classname](hostname)
getattr(instance, methname)()
if __name__ == '__main__':
import plac; plac.call(main)
--
http://mail.python.org/mailman/listinfo/python-list