Martin v. Löwis <mar...@v.loewis.de> added the comment: > For example, starting on line 152 we have, > # Py3K > #return unicode(self.compile()) > # Py2K > return unicode(self.compile()).\ > encode('ascii', 'backslashreplace') > # end Py2K
Ok, I can propose two different spellings of this without any macro processor: A. conditionally encode for 2.x def __str__(self): res = unicode(self.compile()) if sys.version_info < (3,): res = res.encode('ascii', 'backslashreplace') return res B. (if A is deemed to incur too much per-call cost, due to the version test) if sys.version_info >= (3,): def __str__(self): return unicode(self.compile()) else: def __str__(self): return unicode(self.compile()). \ encode('ascii', 'backslashreplace') In addition, I fail to see how the markup hfuru proposed can be used to express this case. IIUC, he asks for markup that can tell 2to3 to leave a certain piece of code alone, i.e. unmodified. I fail to see how this would help in this sqlalchemy example. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue10070> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com