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 terry.reedy
Recipients arjennienhuis, benjamin.peterson, eric.smith, loewis, terry.reedy, uau, vstinner
Date 2011-03-07.00:47:08
SpamBayes Score 6.43429e-11
Marked as misclassified No
Message-id <>
For future reference, struct.pack, not mentioned here, is a binary bytes formatting function. It can mix ascii bytes with binary octets. It works the same in Python 2 and 3.

Str.bytes does two things: convert objects to strings according to the contents of field specifiers; interpolate the resulting strings into a template string according to the locations of the field specifiers. If desired bytes represent encoded text, then encoding computed text is the obvious Py3 solution.

For some mixed ascii-binary uses, struct.pack is not as elegant as a bytes.format might be. But I think such a method should use struct format codes within field specifiers to convert objects into binary bytes rather than text.
Date User Action Args
2011-03-07 00:47:09terry.reedysetrecipients: + terry.reedy, loewis, vstinner, eric.smith, benjamin.peterson, arjennienhuis, uau
2011-03-07 00:47:09terry.reedysetmessageid: <>
2011-03-07 00:47:09terry.reedylinkissue3982 messages
2011-03-07 00:47:08terry.reedycreate