KraftDiner wrote:
> try this:
> 
> class x(object):
>    def __init__(self):
>       self.someName = "hello"
>    def someMethod(self):
>       self.sumName = "bye"
> 
> find that bug.

You forgot to include unit tests for someMethod().  Those would have 
caught the bug.

The reality is that if you aren't doing unit testing, you aren't 
catching other bugs either, bugs which aren't caught by the compile-time 
tests in other languages and which aren't caught by PyChecker or PyLint 
either.  Bugs which are probably much more common than typos like the 
above, too.

Still, if you are really bothered by these things frequently, I believe 
recipes have been posted in the past which *do* allow you to avoid many 
such problems, by declaring the acceptable attribute names somewhere and 
using one of Python's many hooks to intercept and check attribute 
setting.  Check the archives or the CookBook.

-Peter

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to