Nov-02-2018, 02:15 PM
I'm new to Python, and generally speaking am not trained as a programmer. I am using version 3.7 on Windows 8.1, and most of my work so far has been GUI related with wxPython (4.0.3). I have read various parts of PEP 8 in an attempt to learn to program "Pythonically" and so far, I think I'm doing a reasonable job.
My question has to do with the lack of private attributes, and whether it is necessary or "pythonic" to try to limit the numbers of publicly available attributes defined like:
Does this only appear to be an issue due to the use of intellisense (I'm using VS Code as an IDE), or is there a bigger issue around public attributes that I should concern myself with? I have read numerous posts and articles about how to create private-like attributes using single and double underscores, but I don't have a feeling yet regarding if or where I should apply this technique, and how liberally I should do so.
Thanks in advance for the feedback.
My question has to do with the lack of private attributes, and whether it is necessary or "pythonic" to try to limit the numbers of publicly available attributes defined like:
self.attribute = "string"
. To make various aspects of the class available to instance methods, I'm finding myself prepending almost every attribute with self
. The result is that when writing code, intellisense presents everything from strings to sizers as available attributes from outside the class, even though in most cases they aren't needed outside the class.Does this only appear to be an issue due to the use of intellisense (I'm using VS Code as an IDE), or is there a bigger issue around public attributes that I should concern myself with? I have read numerous posts and articles about how to create private-like attributes using single and double underscores, but I don't have a feeling yet regarding if or where I should apply this technique, and how liberally I should do so.
Thanks in advance for the feedback.