Neal Becker wrote: >How can I write code to take advantage of new decorator syntax, while >allowing backward compatibility? > >I almost want a preprocessor. > >#if PYTHON_VERSION >= 2.4 >@staticmethod >... > > >Since python < 2.4 will just choke on @staticmethod, how can I do this? > > Decorators are there because class MyClass: @staticmethod def my_method(arg1, arg2, ...): whatever is nicer than class MyClass: def my_method(arg1, arg2, ...): whatever my_method = staticmethod(my_method) I'm affraid, if you need to be 2.3 compatible then you need to use the later form. Les
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