Is this a good idea or a waste of time?

Antoon Pardon apardon at forel.vub.ac.be
Tue Aug 29 01:45:27 EDT 2006


On 2006-08-29, Gabriel Genellina <gagsl-py at yahoo.com.ar> wrote:
> At Tuesday 29/8/2006 01:28, Antoon Pardon wrote:
>
>> > Antoon Pardon wrote:
>> >> There seem to be enough problems that work with ints but not with
>> >> floats. In such a case enforcing that the number you work with
>> >> is indeed an int seems fully appropiate.
>> >
>> > I've _never_ seen a case where enforcing types in the manner of the OP
>> > is appropriate.
>> >
>> > It fails with trivial wrappers like
>> >
>> > class myInt(int):
>> >     def printFormatted(self):
>> >         ..........
>> >
>> > Even looser checking with isinstance is rarely right.  You may want to
>> > exclude floats, but that doesn't mean you want to exclude int-like
>> > objects that don't inherit from int.
>>
>>That may be true. But one may wonder if this is a failing of the
>>programmer or a failing of the language that doesn't support
>>such things.
>
> In any case, I don't see how this supports the original claim that 
> strict type checking input params is good practice.

I'm not defending that claim. I'm just putting question marks
with the claim that strict type checking input parameters is
bad practice.

-- 
Antoon Pardon



More information about the Python-list mailing list