Possible Duplicate:
Why do you need explicitly have the “self” argument into a Python method?
In Python, instance variables must be accessed via self.x, but global variables can be read by just writing x. How come?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is a frequently asked question, but essentially: it is so as to avoid name conflicts or confusion about which of instance or global variables are being accessed.
The philosophy is “Explicit is better than implicit”.