A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2004-March/043632.html below:

[Python-Dev] method decorators (PEP 318)

[Python-Dev] method decorators (PEP 318)Delaney, Timothy C (Timothy) tdelaney at avaya.com
Sun Mar 28 22:33:53 EST 2004
> From: Greg Ewing
> 
> Particularly considering the latter restriction, I'm wondering whether
> these should be treated differently in the syntax. Maybe something
> like
> 
>   def [type2trans] foo(args) [type1trans, type1trans...]:
>     ...
> 
> or
> 
>   def foo [type2trans] (args) [type1trans, type1trans...]:
>     ...
> 
> This might also help satisfy Guido's concerns about the positioning
> of 'classmethod' and 'staticmethod', since, being type 2 transformers,
> they would go up front.

Hmm - this seems like it has possibilities. Since we could only have one decorator that returned a descriptor, we could dispense with the [] on those, leading to:

    def descriptor_trans func_name (func_args) [callable_trans, callable_trans, ...]:
        ...

e.g.

    def classmethod foo (cls, arg1, arg2) [synchronized(lock)]:
        pass

which I think satisfies most the (IMO) most important requirements that various people have put forwards, namely:

1. `classmethod` and `staticmethod` are very important and should be very obvious (Guido seems absolutely adamant on this);

2. The name of the method should be near `def`;

3. There should be nothing between the name of the function and the arguments.

Tim Delaney

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4