Multi-argument decorators in 2.6
- by wheaties
Generally don't do OO-programming in Python.  This project requires it and am running into a bit of trouble.  Here's my scratch code for attempting to figure out where it went wrong:
class trial(object):
    def output( func, x ):
        def ya( self, y ):
            return func( self, x ) + y
        return ya
    def f1( func ):
        return output( func, 1 )
    @f1
    def sum1( self, x ):
        return x
which doesn't compile.  I've attempted to add the @staticmethod tag to the "output" and "f1" functions but to no avail.  Normally I'd do this
def output( func, x ):
    def ya( y ):
        return func( x ) + y
    return ya
def f1( func ):
    return output( func, 1 )
@f1
def sum1( x ):
    return x
which does work.  So how do I get this going in a class?