try: set except NameError: from sets import Set as set
Syntactical variations notwithstanding, I think it's a common desire to want to run on at least the last few versions of Python, but take advantage of improvements and not emit deprecation warnings on the latest and greatest.
I am considering releasing a forward-compatibility library for installation alongside applications that need to use multiple versions of Twisted, so they can do it in a style which is closer to the new versions than the old ones: perhaps it might be good practice to start doing this for Python as well?
That way instead of multi-line "except NameError" tests all over the place you can simply have one-liner boilerplate for every module in your project:
'from py24compat import *'
Easy to grep/sed for when you're ready to stop supporting old versions, too, for those of you without a copy of the refactoring editor from the 2009 release of PyDev/Eclipse.
The only problem with this idea is that the 2.3 -> 2.4 transition has been extremely smooth for me - there are no new features I desperately want to use, and there are no old features that were deprecated or altered (that I've found yet - knock on wood). Still, future incompatibilties are inevitable.
Of course I'd also like to echo the thanks to Anthony for having relegated this problem to major releases.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com