[Python-Dev] IPython, @, and option E from the wiki (original) (raw)

Fernando Perez fperez528 at yahoo.com
Sat Aug 7 02:25:47 CEST 2004


Hi all,

since the developers have been kind enough to take ipython's fate into account in the decorator debate, I figured I'd post an additional piece of info.

Option E on the Wiki http://www.python.org/moin/PythonDecorators is:

E. pie decorator at top of function body syntax

def foo(arg1,arg2): @classmethod ...

def bar(low,high): @accepts(int,int) @returns(float) ...

I just want to mention a couple of things regarding this one, in case it becomes a contender in Guido's mind:

  1. It would NOT cause ipython any problems whatsoever. Ipython only special-cases @foo at the beginning of a line, so this would be perfectly OK with ipython. I don't know if Leo would fare equally well with it.

  2. I happen to like it quite a bit, since I already consider (because of the special role of docstrings) the top area of a function 'special'. So that area seems to me a reasonable choice for additional meta-information about the function's behavior. I agree decorators are more radical than docstrings, but at least there's a certain conceptual precedent. And it seems to leave the cleanness of the 'def' word which is a nice visible highlight of a function declaration, without causing the deep indentation issues of other proposals.

  3. In this kind of setup, using | instead of @ would be ok as well, I guess:

def bar(low,high): |accepts(int,int) |returns(float) ...

Ok, nobody really wanted my opinion, so feel free to ignore #2/3 :) The main point was #1.

Best,

f



More information about the Python-Dev mailing list