[Python-Dev] 2.4a2, and @decorators

Guido van Rossum guido at python.org
Tue Aug 3 16:50:00 CEST 2004


> Because '[foo]' is absolutely a list with no side effects in today's
> Python.  But '[foo()]' clearly *can* have some side effect, so if
> you're reading the code you have to look up 'foo' to understand
> what's happening there.

Too subtle for the folks who argued against [foo] on grounds of
ambiguity I think.

> This isn't at all sudden, btw: David Abrahams made the first
> 'decorate' proposal in June, and suggested the idea of using the
> debugger hook to implement it.  I thought that one of the best parts
> of David Abrahams' idea was that requiring a function call made the
> [] syntax less ambiguous.

And I think it is one of the worst.  sys.settrace is an implementation
feature not a language feature.

> Well, the other point is that it allows you to use C# syntax.  Note
> that if it were spelled:
> 
>      [classmethod()]
>      def foo(x):
>          ...
> 
> this would also resolve the ambiguity (IMO).

Not IMO, that would just add more mystery (and would require yet
another hack in classmethod to allow it to be called without args).

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


More information about the Python-Dev mailing list