Attack a sacred Python Cow
Russ.Paielli at gmail.com
Sat Jul 26 23:16:42 CEST 2008
> > So why not allow something like this?:
> > class MyClass:
> > def func( , xxx, yyy):
> > .xxx = xxx
> > local = .yyy
> > The "self" argument is replaced with nothing, but a comma is used as a
> > placeholder.
> (+1) but why retain the leading comma in
> the argument list?
As I said, the leading comma is a place holder. Without it, the
interpreter would have no way of knowing that the first argument is
not just another name for "self."
We need to maintain compatibility with existing Python rules. If we
were designing a new language, we could omit the "self" argument in
the signature, and allow either ".xxx" or "self.xxx," at the
programmers discretion (i.e., let "self" be the standard name, like
"this" in C++).
More information about the Python-list