Attack a sacred Python Cow

Colin J. Williams cjw at ncf.ca
Sat Jul 26 17:03:49 EDT 2008


Russ P. 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):
> 
>         .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?

Colin W.



More information about the Python-list mailing list