[Python-Dev] Considering decorator syntax on an individual feature basis (original) (raw)

Martin Zarate mzarate at uoguelph.ca
Thu Aug 19 18:13:11 CEST 2004


Issues with decorator syntax.

I think we can all agree that the decorator argument is now wholly a matter of aesthetic taste, with the brief exception of namespace-based stuff that got argued when I suggested to use a block instead.

The problem is that we keep jumping from the beginning of the argument to the end - we keep saying "what syntax do we want" rather than "which syntactic features do we want".

The features in question, which should be decided individually rather than as a whole:

I think if each of these issues could be resolved and agreed to individually, then a consensis would be far more apparent as to the ideal solution, or at least some of the myriad solutions could be filtered out.

I think the Python community has mostly settled on a "before def" approach, and I think that most agree that the @ character is very ugly, but some are coming around (mostly out of exhaustion though, it sounds). So if we can agree on the latter considerations. Personally, my favourite would be a single-line but continuable statement (like the "import" statement) which causes the assignment that occurs on the following line be wrapped by its mentioned objects. Use a nice keyword like deco or remake (or even just "be"). Possibly indent the def one level to show the relationship of the import statement and to allow for def assignments to look good when used with the statement.

The fact is that there is no Pythonic precedence here - we're talking about a statement that holds one other statement and has N parameters. Whenever Python has had to break into new ground with statements, its been a bit of a mess (take lambda for example).

Oh, and in defense of "be" as a statement - how's this?

be staticmethod, returning(int), taking(int, bool, bool) def foo: pass

or

be ( staticmethod, synchronised): foo = lambda: none

but that's just my tastes. Oh well, I'm violating my own rule, jumping ahead with a full syntax when we can't even find consensus on the parts of it.



More information about the Python-Dev mailing list