How to validate the __init__ parameters

Aahz aahz at
Mon Jan 11 05:54:38 CET 2010

In article <mailman.2244.1261418090.2873.python-list at>,
Jean-Michel Pichavant  <jeanmichel at> 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           <*>

"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