Revised PEP 318 - Function/Method Decorator Syntax

Bengt Richter bokr at oz.net
Thu Jun 12 14:49:00 EDT 2003


On 11 Jun 2003 07:58:35 -0700, mis6 at pitt.edu (Michele Simionato) wrote:

>bokr at oz.net (Bengt Richter) wrote in message news:<bc5nko$4c9$0 at 216.39.172.122>...> 	 syncmeth = (synchronized(lock), classmethod)
>>          def foo(self) as syncmeth:
>>              perform method operation
>> 
>> Is it reasonable to think of this mechanism as a kind of meta-classes for functions?
>> Is there some unification that should not be painted out of the future?
>> 
>> Regards,
>> Bengt Richter
>
>Looks like an interesting idea. Do you have any further thought on that?
>
>                                Michele

Nothing too deep. It just strikes me that functions are objects too, and there are
variations like closures and generators and bound methods etc, yet the process of
creating these things is not exposed for customization in a unified way. I'm not sure
what would be in the dct if cls,name,bases,dct were passed to a meta-something on
completion of the function definition, analogous to metaclass at the completion of
class definition, but I assume the code object would be there and tinkerable at
the __new__ stage in a way that might not be possible later. E.g., being able
to add pre-bound local variables to a function might be interesting (like default
arg values, but not in the arg list).

Maybe with module new and some clever hacks a user function class could be worked up
for concept testing. Lots of handwaving here ;-)

Regards,
Bengt Richter




More information about the Python-list mailing list