Python style: to check or not to check args and data members
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Thu Aug 31 21:08:44 EDT 2006
Joel Hedlund a écrit :
> Hi!
>
> The question of type checking/enforcing has bothered me for a while,
(snip)
>
> I've also whipped up some examples in order to put the above questions
> in context and for your amusement. :-)
(snip)
> These are the attached modules:
>
> * nocheck_module.py:
> As the above example, but with docs. No type checking.
>
> * property_module.py
> Type checking of data members using properties.
>
> * methodcheck_module.py
> Type checking of args within methods.
>
> * decorator_module.py
> Type checking of args using method decorators.
>
> * maximum_security_module.py
> Decorator and property type checking.
You forgot two other possible solutions (that can be mixed):
- using custom descriptors
- using FormEncode
More information about the Python-list
mailing list