[docs] [issue16580] Add examples to int.to_bytres and int.from_bytes

Paddy McCarthy report at bugs.python.org
Sun Dec 9 11:34:49 CET 2012


Paddy McCarthy added the comment:

On 06/12/2012 14:31, Ezio Melotti wrote:
> Ezio Melotti added the comment:
>
> I agree.  The examples in the doc seem clear to me, whereas the ones you proposed are not as clear.  Do you think there's something that they don't currently cover that should be added?
>
> ----------
> nosy: +ezio.melotti
>
> _______________________________________
> Python tracker <report at bugs.python.org>
> <http://bugs.python.org/issue16580>
> _______________________________________
>
First, Thanks Ezio and Andrew for your replies.

My problem was that when working on bitcoin address validation I saw 
code that was shifting and &'ing with 0xFF to convert to multiple bytes 
and half remembered that there might be a Python function to do that. On 
finding the .to_bytes method and its parameter "big" or "little", the 
only way I had of working out which to use was to try each until I found 
out which worked.

I therefore thought that what would have helped me was code that showed 
the equivalent "expanded Python" for the method in a similar way to what 
is done for some of the itertools functions etc.

If we split my request into two:

 1. Is such extra explanation necessary.
 2. Is my specific code that extra explanation.

I can work on the code a bit more.
Have I persuaded you that an extra explanation is necessary?

Thanks, Paddy.

P.S. I guess what is currently present shows the result of the methods 
but nothing on how it could be generated. I am stating that the 
generation can aid comprehension.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16580>
_______________________________________


More information about the docs mailing list