On 2/12/07, Tracy R Reed <[EMAIL PROTECTED]> wrote:
class ServiceConfigDefault:
load_warning=2
load_critical=4
disk_warning=90
disk_critical=95
class ServiceConfig(ServiceConfigDefault):
def __init__(self, **kwargs):
service = kwargs["service"]
if kwargs["load_warning"]:
load_warning=kwargs["load_warning"]
if kwargs["load_critical"]:
load_critical=kwargs["load_critical"]
Did you mean to put "self." in front of load_warning and load_critical
just above? Or did you really want locals? Also:
kwargs["load_warning"] will raise a KeyError if load_warning was not
passed--try kwargs.has_key('load_warning')
But you can slurp up all keyword args like so:
class ServiceConfig(ServiceConfigDefault):
def __init__(self, **kwargs):
ServiceConfigDefault.__init__(self)
for key in kwargs:
setattr(self, key, kwargs[key])
The nice thing about that for loop is that it doesn't need any more
maintenance. It will handle all keyword args all the time for the life
of the software.
HTH,
-Chuck
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg