[Python-Dev] method decorators (PEP 318)

Shane Holloway (IEEE) shane.holloway at ieee.org
Mon Mar 29 15:47:13 EST 2004


grr... spacing didn't quite come out right.  Blasted tabs.  Let's try 
this again:

     class Example(object):
         def foo(self, *args) [
                 synchronized(lock),
                 attributes(author='SWH', protocol=IMyProtocol),
                 myArgumentWireMarshaller,
                 ]:
             pass # Code goes here
         def bar(self, *args) [
                 synchronized(lock),
                 attributes(author='SWH', protocol=IMyProtocol),
                 myArgumentWireMarshaller,
                 ]:
             pass # Code goes here
         def baz(self, *args) [
                 synchronized(lock),
                 attributes(author='SWH', protocol=IMyProtocol),
                 myArgumentWireMarshaller,
                 ]:
             pass # Code goes here

more like:

     class Example(object):
         IMyProtocolMethod = [
             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





More information about the Python-Dev mailing list