Writing bytes to stdout reverses the bytes

Akkana Peck akkana at shallowsky.com
Mon Aug 20 11:07:37 EDT 2018


> Thomas Jollans <tjol at tjol.eu>:
> > Wonderful. Now why don't we all forget about hexdump and use xxd? ;-)

Marko Rauhamaa writes:
> Fedora:
> 
>    $ xxd
>    bash: xxd: command not found
>    $ hd
>    bash: hd: command not found
>    $ od -Ax -tx1z -v <<<hello
>    000000 68 65 6c 6c 6f 0a                                >hello.<
>    000006

Or, since this is Python, why be frustrated over imperfect command
output when you can write something that gives whatever format you
like best?  Long ago the old Unix od used to give something like this,
and when I was learning Python writing it seemed like a good exercise:

$ bdump hello
        >    h    e    l    l    o    .    <   ^J 
  20   3e   68   65   6c   6c   6f   2e   3c    a 
  32   62  104  101  108  108  111   46   60   10 

https://github.com/akkana/scripts/blob/master/bdump

        ...Akkana



More information about the Python-list mailing list