On 06/01/14 13:24, Victor Stinner wrote:
Hi,

bytes % args and bytes.format(args) are requested by Mercurial and
[snip]

I'm opposed to adding methods to bytes for this, as I think it goes against the reason for the separation of str and bytes in the first place.

str objects are pieces of text, a list of unicode characters.
In other words they have meaning independent of their context.

bytes are just a sequence of 8bit clumps.
The meaning of bytes depends on the encoding, but the proposed methods will have no encoding, but presume meaning.
What does b'%s' % 7 do?
u'%s' % 7 calls 7 .__str__() which returns a (unicode) string.
By implication b'%s' % 7 would call 7 .__str__() and ...
And then what? Use the "default" encoding? ASCII?
Explicit is better than implicit.

I am not opposed to adding new functionality, as long as it is not overloading the % operator or format() method.

binascii.format() perhaps?

Cheers,
Mark.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to