This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients arjennienhuis, benjamin.peterson, christian.heimes, eric.smith, exarkun, ezio.melotti, loewis, martin.panter, serhiy.storchaka, terry.reedy, uau, vstinner
Date 2012-10-02.13:55:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1349186145.73.0.841232590156.issue3982@psf.upfronthosting.co.za>
In-reply-to
Content
> I suspect, but have not verified, that having a bytes version of this code would now require an implementation that shared very little with the str version.

This is not all. The usage model will be completely different too.

* The default formatting should not use str(), but buffer protocol.
* There is no place for floating point.
* There is no place for locale.
* There is no place for 'r' conversion (possible only for 'a').
* It should include the features of struct.pack(), int.to_bytes() and ctypes.
* Padding should be not only by space, but also by zeros (and possibly by other values).
* Alignment (padding to position divisible by some number).
* In addition to padding and truncating should be the ability to raise an exception in case of discrepancy between the needed and actual lengths.
* It unlikely needed attribute access and indexing.
* Builtin format() should not work with this.

As a result, this should be a completely separate formatting mini-language that has nothing shared with strings formatting. Not worth to introduce bytes.format(), it's just confused. Perhaps you should add features to struct module or add a new module. PyPI looks as good place for such experiments. If people will use it, it could be included in the stdlib.
History
Date User Action Args
2012-10-02 13:55:45serhiy.storchakasetrecipients: + serhiy.storchaka, loewis, terry.reedy, exarkun, vstinner, eric.smith, christian.heimes, benjamin.peterson, ezio.melotti, arjennienhuis, uau, martin.panter
2012-10-02 13:55:45serhiy.storchakasetmessageid: <1349186145.73.0.841232590156.issue3982@psf.upfronthosting.co.za>
2012-10-02 13:55:45serhiy.storchakalinkissue3982 messages
2012-10-02 13:55:45serhiy.storchakacreate