Attack a sacred Python Cow
Lie.1296 at gmail.com
Sun Jul 27 13:28:55 CEST 2008
On Jul 27, 2:48 am, "Russ P." <Russ.Paie... at gmail.com> wrote:
> > If, as I wrote, you permit the omission of "self" in method signatures
> > defined within class definitions, then you could still insist on
> > instance attribute qualification using "self" - exactly as one would
> > when writing Java according to certain style guidelines.
> I'm not sure exactly what people mean here by allowing "self" to be
> "omitted" in method signatures. If it is omitted, then it seems to me
> that a place holder would be needed to the interpreter that the first
> argument is not just another name for "self."
> In an earlier post on this thread (don't feel like looking it up at
> the moment), someone suggested that member data could be accessed
> using simply ".member". I think he might be on to something. The dot
> is a minimal indicator that the data is a class member rather than
> just local. However, a placeholder is still needed in the signature.
> So why not allow something like this?:
> class MyClass:
> def func( , xxx, yyy):
Why not? Because that would make someone new to python scream in
> .xxx = xxx
> local = .yyy
OTOH, this might come as a handy syntax sugar, this is like With
Statement in VB, although in VB, you have to state explicitly what you
want to call implicitly when using something of the .methods. But I
think implementing this might come with a heavy toll to the parser.
> The "self" argument is replaced with nothing, but a comma is used as a
More information about the Python-list