In Python (I'm talking 2 here, but would be interested to know about 3 too) is there a way to define in advance a list of all instance variables (member fields) you want available i.e. make it an error to use one you've not defined somewhere?
Something like
class MyClass(object):
var somefield
def __init__ (self):
self.somefield = 4
self.banana = 25 # error!
A bit like you do in Java, C++, PHP, etc
Edit:
The reason I wanted this kind of thing was to spot early on using variables that hadn't been setup initially. It seems that a linter will actually pick these errors up without any extra plumbing so perhaps my question is moot...