Class decorators in Python 2.5?

前端 未结 1 1797
抹茶落季
抹茶落季 2021-01-18 21:13

Is there a way I can make class decorators work on Google App Engine, which is limited to Python 2.5?

相关标签:
1条回答
  • 2021-01-18 21:34

    Decorators are just syntactic sugar. Just change instances of decorator usage, that is,

    @decorated
    class Foo(object): pass
    

    becomes

    class Foo(object): pass
    Foo = decorated(Foo)
    

    You can't, realistically, change the parser.

    Though, you could automate the above process using the ast module (in a new version of Python).

    0 讨论(0)
提交回复
热议问题