Possible PEP: Improve classmethod/staticmethod syntax
Russ Salsbury
clpy.NOSPAM at russellsalsbury.com
Tue Jun 3 22:04:23 EDT 2003
Kevin Smith <Kevin.Smith at sas.com> wrote in message news:<20030603164521903-0400 at braeburn.themorgue.org>...
> A new proposed syntax for method modifiers is as follows:
>
> def classmethod foo(cls):
> <code goes here>
>
> def staticmethod bar():
> <code goes here>
>
+1
I think it's a great step forward for clarity. The current scheme
makes it easy to miss the programmer's intent. Another place that
could use a similar improvement is the declaration of properties,
where getfoo and setfoo are genereated from
def property foo(self, val):
""" property doc string """
Also a declarative form of metaclass would be an improvement.
Unfortunately the analagous form doesnt give the expected results:
class meta foo basefoo: ...
This would work
metaclass meta: ...
class foo basefoo meta: ...
Or with less syntactic mayhem:
class foo basefoo, metaa metab: ...
Anyway, food for thought.
-- Russ
More information about the Python-list
mailing list