What's the best way to minimize the need of run time checks?

Chris Angelico rosuav at gmail.com
Fri Aug 12 05:45:42 EDT 2016


On Fri, Aug 12, 2016 at 7:38 PM, BartC <bc at freeuk.com> wrote:
> You can be too dynamic. Take an example like this:
>> class date:
> def __init__(self,d,m,y):
> self.day=d
> self.month=m
> self.year=y
>> d=date(25,12,2015)
>> d.yaer=1999
>> print (d.day,d.month,d.year)
>> 'year' has been spelled wrongly, but this error is not picked up by the
> byte-code compiler and will not immediately be detected at runtime either.
> It will be seen in my example only if someone notices the printout isn't
> what it should be.
>> This would never get past a static language nor some that also have dynamic
> types.

Nor will it get past a lot of linters. Or unit tests. There are other solutions.
ChrisA


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /