Terry Reedy, 01.01.2011 23:47:
1. Code running in multiple versions has to be syntactically correct in
every detail all versions in order to be compiled without error. However,
version specific syntax *can* be used in modules that are conditionally
imported and therefore conditionally compiled and executed.

This is something that might also be a suitable solution for the OP's problem. The format strings can be by externalised into an importable module, which can then be duplicated to use the 'b' bytes prefix for Python 3.

The obvious drawback is that this moves the strings out of the immediate sight of someone reading the sources, and that it requires the two string modules to be kept in sync. But at least for the synchronisation, a simplistic conversion tool run during installation could do the trick.

Stefan

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to