homepage

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 steven.daprano
Recipients Padmanabhan.Tr, steven.daprano
Date 2015年07月09日.00:43:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20150709004321.GH10773@ando.pearwood.info>
In-reply-to <1485663175.588766.1436367052388.JavaMail.yahoo@mail.yahoo.com>
Content
I'm sorry, but I believe that you have misunderstood what happens here. 
This has nothing to do with the hex codec, or int.to_bytes() etc. This 
is the standard property of byte strings in Python, that they are 
displayed using ASCII as much as possible.
The byte string b'\x41' is just the hex escape form for the byte string 
b'A' (ASCII capital A). It doesn't matter whether you use ASCII, 
decimal, octal or hexadecimal, you get an equal byte string:
 py> b'A' == bytes([65]) == b'101円' == b'\x41'
 True
with the same internal byte value. When you print a byte string, Python 
prefers to display it using ASCII characters where possible regardless 
of whether it was constructed from backslash escapes or not. So the byte 
string b'\x41 A \xEF' prints as b'A A \xef' because \x41 is the ASCII 
character A, but \xEF has no ASCII representation so it remains in hex 
escape form. It doesn't matter where that byte string comes from: the 
hex codec, int.to_bytes, or somewhere else.
I don't think this is appropriate to continue discussing this on the bug 
tracker. If you would like to continue the discussion, please join the 
python-list@python.org mailing list, or comp.lang.python newsgroup, and 
I'll be happy to discuss it further there.
History
Date User Action Args
2015年07月09日 00:43:42steven.dapranosetrecipients: + steven.daprano, Padmanabhan.Tr
2015年07月09日 00:43:42steven.dapranolinkissue24551 messages
2015年07月09日 00:43:39steven.dapranocreate

AltStyle によって変換されたページ (->オリジナル) /