Possible PEP: Improve classmethod/staticmethod syntax

Skip Montanaro skip at pobox.com
Wed Jun 4 17:21:07 CEST 2003

    gca> Since decorators are in a dictionary, in what order should they be
    gca> applied? I though item extraction from a dictionary was, basically,
    gca> unordered.

Correct.  The advantage of a dictionary is that the individual elements can
be more complex.  For the pre- and post-condition stuff this works well.  To
use lists there you have to extend list constructor syntax somehow, as I
used in my original message:

    def foo(...) [pre=foo_pre, post=foo_post]:
        <normal code here>

You could also use strings:

    def foo(...) ['pre=foo_pre', 'post=foo_post']:
        <normal code here>

The compiler would presumably split them at the '=' and eval() the right
hand side where necessary to get at the actual value.

    gca> The idea of keeping them in a list (syntax #1) was that it's easy
    gca> to see the order they're going to be applied to the original
    gca> function.



More information about the Python-list mailing list