
Ich hab ein Programm welches nur ein Aktions-Argument benötigt... Meine bisherige Lösung:
Code: Alles auswählen
#!/usr/bin/python
# -*- coding: ISO-8859-1 -*-
"""
install - Install PyAdmin as inetd services
deinstall - DeInstall PyAdmin (inetd services)
start - Start stand alone PyAdmin server
stop - Stops a runing stand alone PyAdmin server
"""
import optparse
OptParser = optparse.OptionParser( usage = __doc__ )
options, args = OptParser.parse_args()
if len(args) != 1:
OptParser.error("wrong argument!")
action = args[0]
if action == "install":
install()
elif action == "deinstall":
deinstall()
elif action == "start":
start_server()
elif action == "stop":
stop_server()
OptParser.error("wrong argument!")