why is "self" used in OO-Python?
fredrik at pythonware.com
Tue Jul 15 13:10:15 CEST 2008
> def append(self, item):
> I can get to see the stack with var.stack but then why even implement
> append when I could do self.stack.append(x) etc.
> That way you could do away with OO completely.
Umm. Even if you were to write that, self and stack would still be
objects, and the "append" would still be a method defined by the stack
What you seem to be referring to is the Law of Demeter, which is a
design guideline for avoiding unnecessary coupling, not an absolute
requirement for object-orientation:
As for the rest, I suspect you will have more success in using Python if
you use it to write Python programs, not Java programs:
More information about the Python-list