[Python-Dev] RFC: PEP 460: Add bytes % args and bytes.format(args) to Python 3.5
Eric V. Smith
eric at trueblade.com
Fri Jan 10 23:20:32 CET 2014
On 1/10/2014 5:12 PM, Victor Stinner wrote:
> 2014/1/10 Juraj Sukop <juraj.sukop at gmail.com>:
>> In the case of PDF, the embedding of an image into PDF looks like:
>>
>> 10 0 obj
>> << /Type /XObject
>> /Width 100
>> /Height 100
>> /Alternates 15 0 R
>> /Length 2167
>> >>
>> stream
>> ...binary image data...
>> endstream
>> endobj
>
> What not building "10 0 obj ... stream" and "endstream endobj" in
> Unicode and then encode to ASCII? Example:
>
> data = b''.join((
> ("%d %d obj ... stream" % (10, 0)).encode('ascii'),
> binary_image_data,
> ("endstream endobj").encode('ascii'),
> ))
Isn't the point of the PEP to make it easier to port 2.x code to 3.5? Is
there really existing code like this in 2.x?
I think what we're trying to do is to make code that looks like:
b'%d %d obj ... stream' % (10, 0)
work in both 2.x and 3.5.
But correct me if I'm wrong. I'll admit to not following 100% of these
emails.
Eric.
More information about the Python-Dev
mailing list