How to validate the __init__ parameters
Aahz
aahz at pythoncraft.com
Sun Jan 10 23:54:38 EST 2010
In article <mailman.2244.1261418090.2873.python-list at python.org>,
Jean-Michel Pichavant <jeanmichel at sequans.com> wrote:
>
>class A:
> def __init__(self, foo = None, bar = None):
> if len(foo) > 5:
> raise ValueError('foo cannot exceed 5 characters')
Bad Idea -- what happens when foo is None?
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"If you think it's expensive to hire a professional to do the job, wait
until you hire an amateur." --Red Adair
More information about the Python-list
mailing list