[Python-Dev] Re: PEP 318: Decorators last before colon (original) (raw)
Phillip J. Eby pje at telecommunity.com
Wed Mar 31 22:32:20 EST 2004
- Previous message: [Python-Dev] Re: PEP 318: Decorators last before colon
- Next message: [Python-Dev] Expert floats
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 07:39 PM 3/31/04 -0500, Neil Schemenauer wrote:
On Wed, Mar 31, 2004 at 07:16:06PM -0500, Phillip J. Eby wrote: > [Binding to the last function definition] doesn't do what's > needed, since you left out the rebinding of the function name.
That's possible without new syntax. Some example code: [snip]
It's not pretty but it might prevent people from developing RSI while Guido works out what new syntax is best.
Actually, one use case for the syntax that isn't possible now, even with frame hacking like your example, is generic functions. That is, I'd like to do something like:
def foo(bar,baz) [generic(int,int)]: # code to foo two integers
def foo(bar,baz) [generic(str,int)]: # code to foo a string and an integer
etc. The idea here is that the object returned by 'generic()' looks to see if the existing definition of 'foo' is a generic function, and if so, adds the current function to the generic function's definition, and then returns the generic function.
This use case isn't possible with any syntax today, without renaming either the generic function or the individual functions, plus twice as many repetitions of the names.
- Previous message: [Python-Dev] Re: PEP 318: Decorators last before colon
- Next message: [Python-Dev] Expert floats
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]