Validation of parameters

Kless jonas.esp at googlemail.com
Sun Aug 10 04:13:08 EDT 2008


Which is the best mode for validation of parameters? I'm using the
next way but it is not well testable.

-----------------------------
if not self._foo:
    try:
        raise ValueError('ValueError: foo not found')
    except ValueError, err:
        print (err.message)
        print("Valid values: %s\n" % self.valid_foo)
        sys.exit(1)

...
...
-----------------------------



More information about the Python-list mailing list