[issue24551] byte conversion
Padmanabhan Tr added the comment: On Wednesday, July 8, 2015 7:56 PM, padmanabhan T R trp...@yahoo.com wrote: Dear Mr Steven D'ApranoI have not gone through the relevant Source Codes; purely based on my working with Python3 (Version 3.4.2) and the 'The Python Library Reference manual, Release 3.4.2' document, I have the following to suggest as additions to this Manual: - Insert the following under 'codecs.decode(obj [,encoding[,errors]])' - Section 7.2, Page 142 : When a bytes objectis decoded with 'hex' decoding, the corresponding returned array hasASCII characters for byte pairs wherever possible; other byte pairsappear as such. The reverse holds good for encoding. import codecs codecs.encode(b'\x1d\x1e\x1f !','hex') b'1d1e1f202122' codecs.encode(b'\x1d\x1e\x1f\x20\x21\x22','hex') b'1d1e1f202122' codecs.decode(b'1d1e1f202122','hex') b'\x1d\x1e\x1f !' codecs.encode(_,'hex') b'1d1e1f202122' codecs.decode(b'3031323334','hex') b'01234' codecs.encode(_,'hex') b'3031323334' codecs.decode(b'797a7b7c7d7e7f8081','hex') b'yz{|}~\x7f\x80\x81' codecs.encode(_,'hex') b'797a7b7c7d7e7f8081' codecs.encode(b'\x79\x7a\x7b\x7c\x7d\7e\x7f\x80\x81','hex') b'797a7b7c7d07657f8081' - Under 'int.to_bytes() - classmethod int.to_bytes()' - Section 4.4.2, Page 31 insert: 'See codecs.decode() also' - Under 'int.to_bytes() - classmethod int.frombytes()' - Section 4.4.2, Page 31 insert: 'See codecs.decode() also' - Under 'classmethod bytes.fromhex(string)' - Section 7.2, Page 142 insert: 'See codecs.decode() also' Padmanabhanm On Wednesday, July 8, 2015 8:57 AM, padmanabhan T R trp...@yahoo.com wrote: On Tuesday, July 7, 2015 9:22 PM, Steven D'Aprano rep...@bugs.python.org wrote: Steven D'Aprano added the comment: Bytes in Python 3 do use ASCII representation: py b'\x41' == b'A' # ASCII True If you think the documentation is unclear, please tell us which part of the docs you read (provide a URL) and we will see if it can be improved. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24551 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24551 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24551] byte conversion
Padmanabhan Tr added the comment: Dear Mr Steven D'ApranoThanks for your prompt response.I guess that 'b'\x00\x00 0' is the same as b'\x00\x00\x20\x30' if we take (space) as 20 0 as 30 as with ASCII / UTF-8 representation. But if I go by 'Python Library Reference -Release version 3.4.2 (Section 4.4.2) ' there is no room for ASCII / UTF-8 representation here. Direct byte conversion is used.Please confirm whether I am right.RegardsPadmanabhan On Thursday, July 2, 2015 10:20 PM, Steven D'Aprano rep...@bugs.python.org wrote: Steven D'Aprano added the comment: I don't know, what *is* the problem? What behaviour did you expect? The code sample you show seems to be working exactly as it is supposed to. b'\x00\x00 0' is the same as b'\x00\x00\x20\x30', and that is the same as b'\x20\x30' with NUL padding on the left. Written as integers, that is like 0x2030 == 0x2030 == 8240. I don't think this demonstrates a bug or problem. If you still believe it does, please re-open the issue with a detailed description of what behaviour you expected and why you think this is a bug. -- nosy: +steven.daprano resolution: - not a bug status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24551 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24551 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24551] byte conversion
New submission from Padmanabhan Tr: I have copied below an execution sequence. What is the problem? x = 8240 x.to_bytes(4,byteorder='big') b'\x00\x00 0' int.from_bytes(b'\x00\x00 0',byteorder='big') 8240 int.from_bytes(b'\x20\x30',byteorder='big') 8240 -- components: +Demos and Tools ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24551 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24551] byte conversion
Changes by Padmanabhan Tr trp...@yahoo.com: -- nosy: Padmanabhan.Tr priority: normal severity: normal status: open title: byte conversion type: behavior versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24551 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24392] pop functioning
New submission from Padmanabhan Tr: I have attached the python sequence my comments. I use Python version 3.4.2 I guess a bug need be corrected -- components: Regular Expressions files: bug_a messages: 244897 nosy: Padmanabhan.Tr, ezio.melotti, mrabarnett priority: normal severity: normal status: open title: pop functioning type: behavior versions: Python 3.4 Added file: http://bugs.python.org/file39638/bug_a ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24392 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22532] A suggested change
New submission from Padmanabhan Tr: Take a complex number n = 3+4j. n.real is taken as 3.0 n.imag as 4.0 in Python3. One has to use the int(0 function to get back the parts as integers. I guess this is a compiler error? -- messages: 228073 nosy: Padmanabhan.Tr priority: normal severity: normal status: open title: A suggested change type: compile error versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22532 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22532] A suggested change
Padmanabhan Tr added the comment: Dear Mr SpearThanks for the prompt response clarification.(in Python) If the real imaginary parts of numbers you deal with are integers, results of operations (except division) - like +, -, *, **, - appear with respective integers as real imginary parts. In line with these, changes in '.real' '.imag' may be desirable? On Wednesday, October 1, 2014 8:19 PM, Eric V. Smith rep...@bugs.python.org wrote: Changes by Eric V. Smith e...@trueblade.com: -- resolution: - not a bug stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22532 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22532 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com