What's a good way to keep track of class instance variables in Python? -


I am a C ++ programmer which is just starting to learn Python I want to know that in large Python classes How do you keep track of the example variables? I am used to keep a .h file which gives me a clear list of all class members (complete with comments) but since Python allows you to add new instance variables on the fly So, how do you track them all?

I am painting a scenario where I am already adding a new example variable, but it was 1000 lines from where I was working. What are the standard practices to avoid this?

Edit: It appears that I have created some confusion with the word "member variables". I really mean the example variable, and I have edited my question accordingly.

First of all: class properties, or example attributes? Or both? =)

Usually you just add the __ init __ class definition before class definition, and the example attributes in the class attributes ... which Probably possibly covering 90% of used cases.

If the code adds attributes on the fly, then it is probably (hopefully :-) good reasons to do this ... the benefits of dynamic features, introspection, etc. Apart from this, adding such features is probably less common in your opinion.


Comments