Why do you need explicitly have the "self" argument into a Python method? -
when defining method on class in python, looks this:
class myclass(object): def __init__(self, x, y): self.x = x self.y = y but in other languages, such c#, have reference object method bound "this" keyword without declaring argument in method prototype.
was intentional language design decision in python or there implementation details require passing of "self" argument?
i quote peters' zen of python. "explicit better implicit."
in java , c++, 'this.' can deduced, except when have variable names make impossible deduce. need , don't.
python elects make things explicit rather based on rule.
additionally, since nothing implied or assumed, parts of implementation exposed. self.__class__, self.__dict__ , other "internal" structures available in obvious way.
Comments
Post a Comment