encapsulation checking features

Eric Scharff edsZZZ_2 at yahoo.com
Mon Apr 14 21:57:12 CEST 2003


I love python's semantics for rapid prototyping, but I was wondering if
there was a way to turn on warnings so that for other kinds of code, I
can avoid certain common uglinesses. :)

Specifically, is there a "lint-like" tool to:

 * warn if instance variables are created outside of a constructor?

  class K:
    def __init__(self):
      self.a = 6  #okay
    def example(self):
      self.b = 66 # not as good

  myVar = K()
  myVar.c = 666  # really bad

 * warn if instance variables are used outside of instance methods
   (encouraging the use of getters and setters)
  
These are great features to have, but it'd be nice to have warnings to
discourage their use at times.

-Eric
 (genuine email replies, remove ZZZ from email address)




More information about the Python-list mailing list