A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/296857.html below:

@staticmethod, backward compatibility?

@staticmethod, backward compatibility?Laszlo Zsolt Nagy gandalf at designaproduct.biz
Tue Sep 27 08:19:22 EDT 2005
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



More information about the Python-list mailing list

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