Syntax modification idea: (classmethods, properties locking...)
Kevin Smith
Kevin.Smith at sas.com
Fri Jan 17 09:45:27 EST 2003
This matter was brought up when classmethod/staticmethods were first
introduced (coincidentally, by me). My favorite solution at the time (I
don't remember who introduced it) was:
def classmethod foo(...):
def staticmethod bar(...):
Under the covers, this could do the same thing as 'foo = classmethod(foo)
', but would also allow people to write their own modifiers. Chaining
them could look like:
def classmethod protected foo(...):
and would effectively do 'foo = classmethod(protected(foo))'. I really
hope this gets more attention because I find the current method of
creating static and class methods so distasteful that I usually try to
avoid them.
In <fuk70b.il3.ln at beastie.ix.netcom.com> Dennis Lee Bieber wrote:
> Arne Koewing fed this fish to the penguins on Thursday 16 January 2003
> 01:03 pm:
>
>>
>> why not extending the def statement?
>>
>> class bar(object):
>> def foo(class,arg1) is classmethod:
>> pass
>> def bar(arg1) is staticmethod:
>> pass
>
> I think I'd prefer just modifying the def keyword...
>
> defclass ...
> defstatic ...
>
> with plain def retaining the effect it has at present.
>
> "is" already has meaning in the language when doing compares --
> I'd rather not overload it as a noise verb "def ... [is] classmethod:
> " wouldn't change if one left out the "is".
>
--
Kevin Smith
Kevin.Smith at sas.com
More information about the Python-list
mailing list