Simple converter of files into their hex components... but i can't arrange utf-8 parts!

blatt447477 at gmail.com blatt447477 at gmail.com
Mon Jun 10 13:01:01 EDT 2013


Hi Chris,
your critics are welcome! But perhaps the majority of them has been
caused by font problems in my posting.
Google should put as default a "mono" font!
Or perhaps it has been a mistake on my part to not configure
correctly the output of my post (I even didn't change my nickname...
so you read a selfish "me" instead of "Blatt"!).
I will try in this reply to have a more readable output, but I'm not
sure... (I need help from experts!...).
By now, the only advice is to copy/paste my post in an editor.

Coming to your critics...

01
>> Functions and classes are entirely optional in Python :)
Together with my not being 'pythonic', is correct...
but it is so difficult to change programming style at my age!...

02
> 004 # qwerty: not _ unicode but _ ascii
> ___ 2 7767773 667 _ 7666666 677 _ 676660
> ___ 3 175249a ef4 _ 5e93f45 254 _ 13399a
>
> 005 # qwerty: non è unicode bensì ascii
> ___ 2 7767773 666 ca 7666666 6667ca 676660
> ___ 3 175249a efe 38 5e93f45 25e33c 13399a

>>I'm not 100% sure of what you're trying to accomplish here.

As you can see from the corrected output (I hope!), I indeed
am trying to produce a hex-dump output ('_' is a "place-holder"
for space which itself is not considered for hex output).
The 2s and 3s are not lines 2 and 3, but 23 in vertical (hex of #)!
In the editor  you can better see my problem with utf-8 chars...
They cause the lack of synchronization. For example 'unicode' after
the utf-8 char is no more synchronized with it's corresponding hex.
To keep the synchronization, you should insert a space after the
utf-8 char... but I didn't succeeed (at least programmatically...).

03
>> ...you consider targeting Python 3.
I probably will never use Python 3! I am perfectly happy with bugfixes
and security patches...
The reason is that I don't need all the "bells and whistles" of Py3,
especially in the field of OOP!

04
>> You can do (synchronization) by simply opening the file as
>> Latin-1 (iso-8859-1) instead of UTF-8.
I already synchronized the output... but afterwards in the editor...
I want to do this programmatically, so I can use it from the
consolle with bash and pipes.

05
>> Or perhaps it'd be better to string them out further vertically?
I considered this solution, but if I succeed in synchronizig all
programmatically... there is not such a difference.

06
>> ... reading the entire file in before producing any output
No problems of speed...

07
>> lP=[]
>> I have no idea what this name is supposed to represent
Simply a list initialization to empty...

08
>> Here's a really fancy trick you can do: Slicing with a step.
Your solution is much better!

I can go further, but it's better that you run my script (if you want)
to get a better understanding. If you are really interested, you can also
try your version (probably better... I will try it).

Bye, Blatt.





More information about the Python-list mailing list