[Python-Dev] PEP 318 bake-off? (original) (raw)

Guido van Rossum guido at python.org
Thu Apr 1 00:44:44 EST 2004


Despite some positive responses, my proposal (which was originally due to Jim Hugunin, who probably has more C# experience than all of us arguing together) is getting some tough opposition. I'd like to have a bake-off, where we view a serious amount of code using decorators to the hilt with each of three proposed syntaxes:

  1. Last-before-colon:

    def foo(cls, arg1, arg2) [funcattrs(foo=42), deprecated, overrides, classmethod]: pass

  2. Prefix list:

    [funcattrs(foo=42), deprecated, overrides, classmethod] def foo(cls, arg1, arg2): pass

2a) Prefix list with leading *:

*[funcattrs(foo=42), deprecated, overrides, classmethod] def foo(cls, arg1, arg2): pass

  1. Prefix suite (could use a different keyword than 'decorate'):

    decorate: funcattrs(foo=42) deprecated overrides classmethod def foo(cls, arg1, arg2): pass

None of the other positions between def and arglist are acceptable any more; a keyword after the argument list isn't acceptable; I don't think any syntax that puts the decorators inside the body (between the colon and the docstring) will work. So this is the field.

What I'm asking (especially of Phillip) is to collect a set of realistic method declarations using decorators; we can then collectively format these using any of the possible syntaxes, and see how they look. We can also review different ways of spreading multiple decorators across several lines, e.g.

[funcattrs(foo=42), deprecated, overrides, classmethod] def foo(cls, arg1, arg2): pass

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list