How to validate the __init__ parameters
jeanmichel at sequans.com
Mon Jan 11 14:52:51 CET 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?
That perfectly illustrates how the simplest solution is the often most
valuable one: it is much more easy to find bugs, when there is any.
More information about the Python-list