Rather than decorators, how about sections?

Paul Morrow pm_mon at yahoo.com
Fri Aug 13 14:46:37 EDT 2004


Steve wrote:
> Then, later, Paul Morrow wrote:
> 
>  > Fine, instead of Foo (the name of the class), use the > word klass.  
> It's a popular name for the first
>  > parameter of a class method.
> 
> "klass" isn't a word. It is a twee deliberate mispelling of a word.
> 
> It also runs the risk of causing confusion when code is spoken aloud (eg 
> in actual human-to-human communication using alternating high and low 
> pressure atmospheric waves to deliver packets of information, or in text 
> readers for the blind).
> 
> It is bad enough when coders (including myself) choose to deliberately 
> mispell words, but to make it required is unforgivable.
> 
> 

Ok I believe that's one vote against 'klass' as a reserved word :-)

Then let it be 'cls', which is also popular.  Or heck, to be flexible, 
let it be something you can specify (as an environment variable, 
compiler setting, etc.).  The important point is that we should resist 
changes to the language that require that the developer specify things 
that are already clearly inferred thru the form/structure of his/her 
code.  We don't have to specify (with curly braces or whatever) where 
code blocks start and end, because the form of our code tells us that. 
It seems natural (to me, and at least one other person) to let the form 
of a function's formal parameter list designate the type of function:

  - if the 1st parameter is named 'self', it's an instance method.
  - if the 1st parameter is 'cls' (or perhaps some suitable synonym), 
it's a class method.
  - for all other parameter arrangements, including no parameters, it's 
a static method.

Simple, clear, obvious, intuitive, and I'm sorry, but this is the least 
ugly of all the alternatives.  There is nothing beautiful about at 
signs, superflous code, clutter...




More information about the Python-list mailing list