class Foo: @staticmethod def keyErrorOnRed(f, colour): if colour == "red": raise KeyError("Better dead than red") return lambda: f(*args, **kwargs) class Bar(Foo): @Foo.keyErrorOnRed("red") def __init__(self, a, b): self.vars = a, b if __name__ == '__main__': barObj = Bar('can', 'haz')
Standard input is empty
Standard output is empty
Traceback (most recent call last): File "prog.py", line 8, in <module> class Bar(Foo): File "prog.py", line 9, in Bar @Foo.keyErrorOnRed("red") TypeError: keyErrorOnRed() takes exactly 2 arguments (1 given)
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!