Two minor syntactic proposals

Roy Katz katz at Glue.umd.edu
Sat Jun 16 23:43:56 EDT 2001


Hello Gareth,

I am interested to know what you find inelegant about the existing
define-a-function-and-bind-it-to-a-class (d-b-c) idiom?

Look at it this way:  The "in .. def" statement's only usable purpose is
to implement something which can already be done..

There was a similar proposal to add 'aliasing' to Python with a
"alias X: existingVar" statement, but Alex M. very nicely stated that a
simple '=' is elegant enough. 


With regards to your latter proposal, again: having 'self' as the first
argument is *so* critical.   Say class C has a method foo, and
an instance c.  When one calls 'c.foo()', the interpreter calls
C.foo(c)'.  That is why 'self' is the first argument to a method. 
I suppose.. one could modify the interpreter to allow
statements like these:

  class C:

    def self.x(...): pass   # method
    def C.x(...): pass      # static or class method

but then, 'self' was never a special keyword... 


Roey
(note also that static methods can be implemented in modules instead of in
classes.  I like this approach because I hate my CompSci instructors, who 
like C++ and /insist/ on being able to define class methods
(imbecilic concept IMHO.  print>>^H^H ). But that's just me. 




More information about the Python-list mailing list