I have been learning Python by following some pygame tutorials.
Therein I found extensive use of the keyword self, and coming from a primarily Java background, I find that I keep forgetting to type self. For example, instead of self.rect.centerx I would type rect.centerx, because, to me, rect is already a member variable of the class.
The Java parallel I can think of for this situation is having to prefix all references to member variables with this.
Am I stuck prefixing all member variables with self, or is there a way to declare them that would allow me to avoid having to do so?
Even if what I am suggesting isn't pythonic, I'd still like to know if it is possible.
I have taken a look at these related SO questions, but they don't quite answer what I am after:
selfis not part of the python syntax. It's just a variable name. You can use any name you want. Also, python methods when called, are always implicitly passed with at least one argument in the first spot. That argument is the instance. That's why it gives you an error if you forget to define a parameter.