How to validate the __init__ parameters

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Tue Dec 22 04:36:01 EST 2009


Denis Doria a écrit :
> Hi;
> 
> I'm checking the best way to validate attributes inside a class. Of
> course I can use property to check it, but I really want to do it
> inside the __init__:

If you use a property, you'll have the validation in the initializer AND 
everywhere else too. If you care about validating the attribute in the 
initializer then you probably want to make sure the attribute is 
_always_ valid, don't you ???



More information about the Python-list mailing list