It's possible to write code that works in both, though it may not be particularly elegant, especially if you use unicode strings. You'd need to use things like
"".encode("ascii").join(slist)instead of just
b"".join(slist)if slist is a list of byte strings. And use
try: f = open(filename,mode) except IOError: s = sys.exc_info()instead of
except IOError, s:or
except IOError as s:
Though it also depends on your 2.x baseline; 2.6 already supports a lot of the 3.x syntax. Supporting all the way up from less than 2.2 (not to mention 1.5.2) is going to be much more painful though, as 2.1 supports has_key() but not "in" for dictionaries, and 3.x is the other way around.
Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds