[Python-Dev] PEP 460: allowing %d and %f and mojibake (original) (raw)

Paul Moore p.f.moore at gmail.com
Sun Jan 12 20:46:39 CET 2014


On 12 January 2014 19:30, Emile van Sebille <emile at fenx.com> wrote:

len(open('chars','wb').write("".join(map (chr,range(256)))).read())

Python 2:

len(open('chars','wb').write("".join(map (chr,range(256)))).read()) Traceback (most recent call last): File "", line 1, in AttributeError: 'NoneType' object has no attribute 'read'

I could be facetous and say "None.read", but more seriously, what are you trying to say here? How do I write a 256-byte file with one byte for each value? bytes(range(256)) gives you the bytestring you want. I simply don't see your point here.

And yet I still don't follow what you want. Unless it's that b'%d' % (12,) must work and give b'12', and nothing else is acceptable. Nothing else is ideal. I'll go that route if I have to. I understand that in the real world you go with what works, but in the development stage you fight for the ideal. :)

OK, but can you fight by giving arguments as to why it's better than the plethora of alternatives that have been suggested? Or counter-arguments to the objections that have been raised to the proposal?

Paul



More information about the Python-Dev mailing list