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/043678.html below:

[Python-Dev] method decorators (PEP 318)

[Python-Dev] method decorators (PEP 318)Shane Holloway (IEEE) shane.holloway at ieee.org
Tue Mar 30 01:16:04 EST 2004
Greg Ewing wrote:
> "Shane Holloway (IEEE)" <shane.holloway at ieee.org>:
> 
> 
>>  def foo(self, *args) [methodreturns(float)] + IMyProtocolMethod:
>>      pass # Code goes here
> 
> 
> Under the current proposal, that wouldn't be allowed.
> You'd need a helper function of some sort that turned
> a list of decorators into a single decorator:
> 
>   def foo(self, *args) [methodreturns(float),
>                         decoratorlist(IMyProtocolMethod)]:
> 
> or, using the extension I proposed a while back,
> 
>   def foo(self, *args) [methodreturns(float), *IMyProtocolMethod]:
> 

I think that reads the best, but then I'd start to want it with normal
lists, too.  ;)

And I did think of the decoratorlist work-around, but I hadn't thought
that you could just as easily do the following:

     class Example(object):
         IMyProtocolMethod = decoratorlist(
             synchronized(lock),
             attributes(author='SWH', protocol=IMyProtocol),
             myArgumentWireMarshaller)

         def foo(self, *args) [methodreturns(float), IMyProtocolMethod]:
             pass # Code goes here
         def bar(self, *args) [methodreturns(str), IMyProtocolMethod]:
             pass # Code goes here
         def baz(self, *args) [methodreturns(int), IMyProtocolMethod]:
             pass # Code goes here

Which makes me just as happy again.  :)  I hope you all had a good time
at PyCon.  One of these years I look forward to meeting all of you.

Cheers,
-Shane Holloway


p.s. sorry for the repeat Greg ;)

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