|
Re: Python 3K or Python 2.9?
|
Posted: May 8, 2008 9:17 AM
|
|
I think the main point people are making about the "explicit" self is it's _not_ always explicit. It's actually the "inconsistently explicit" self. It's explicit if you're defining a method and implicit if you're calling one. This is the problem. Why isn't it explicit all around? Well, if it was then typing self all the time would get ridiculous and noone would use python. Plus, which self would you be referring to when you called an intance.method(self,a,b,c)? The self of the instance or the self that was explicitly defined in the method from which you are calling?
As it is typing self all the time is only ridiculous inside methods. Which is still a good bit, but people tolerate it because otherwise python is an excellent language. If explicit self were gotten rid of or made optional a whole lot of new programmers would adopt the language. I know "consistent" in the python community really means "only one way to do things" in contrast with perl, but a significant change like that might require a version where it's optional as not to break every bit of code out there. Although, maybe not, fixing legacy code would just require a regular expression substitution of 's/( *self *,/(/'... and voila, compatible code (the self.variable references within a method would still work). We could also get rid of the inconsistency with number of parameters _explicitly_ called in a method call equalling the number of parameters _implicitly_ identified by the interpreter.
--David
|
|