On 08.01.2014 11:12, Victor Stinner wrote:
Hi,
2014/1/8 M.-A. Lemburg <mal@egenix.com>:
I'd simply copy over the Python 2 PyString code and start working from there.
It's not possible to reuse directly all Python 2 code because some helpers have been modified to work on Unicode. The PEP 460 adds also more work to other implementations of Python.
IMO some formatting commands must not be implemented. For example, alignment is used to display something on screen, not in network protocols or binary file formats. It's also why the issue #3982 was stuck, we must define exactly the feature set of the new methods (bytes % args, bytes.format).
I'd use practicality beats purity here. As I mentioned in my reply, such formatting methods would indeed be used on data that is text. It's just that this text would be embedded inside an otherwise binary blob. You could do the alignment in Unicode first, then encode it and format it into the binary blob, but really: why bother with that extra round-trip ? The main purpose of the readdition would be to simplify porting applications to Python 3, while keeping them compatible with Python 2 as well. If you need to do the Unicode round-trip just to align a string in some fixed sized field, you might as well convert the whole operation to a function which deals with all this based on whether Python 2 or 3 is running and you'd lose the intended simplification of the readdition. PS: The PEP mentions having to code for Python 3.0-3.4 as well, which would don't support the new methods. I think it's perfectly fine to have newly ported code to require Python 2.7/3.5+. After all, the porting effort will take some time as well. -- Marc-Andre Lemburg eGenix.com Professional Python Services directly from the Source (#1, Jan 08 2014)
Python Projects, Consulting and Support ... http://www.egenix.com/ mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::::: Try our mxODBC.Connect Python Database Interface for free ! :::::: eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/