473,385 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Hex editor - Python beginner's code open to review

CC
Hi:

http://web.newsguy.com/crcarl/python/hexl.py

This is my first Python program other than tutorial code snippet
experimentation. I chose a hex line editor. I may do a hex screen
editor once this is done, if I feel like playing with the curses module.
Or move straight to wxPython.

This is unfinished, and is really just a hex viewer at this point. It
seems like a good point to stop and see what others think. I would be
interested to hear any comments.

My command parsing if of course crude, brute-force, and not very
scalable. I am doing some reading on this subject, and will be trying
to do a more generalized approach in the next revision. This is going
to be a subject where I need to learn a lot, because I have 2-3
embedded applications in C that need varying levels of command parsers,
so I will be seeking to improve this skill considerably.

Thanks for input.

--
_____________________
Christopher R. Carlen
cr***@bogus-remove-me.sbcglobal.net
SuSE 9.1 Linux 2.6.5
Aug 11 '07 #1
2 3425
On Aug 10, 10:36 pm, CC <cr...@BOGUS.sbcglobal.netwrote:
Hi:

http://web.newsguy.com/crcarl/python/hexl.py

This is my first Python program other than tutorial code snippet
experimentation. I chose a hex line editor. I may do a hex screen
editor once this is done, if I feel like playing with the curses module.
Or move straight to wxPython.

This is unfinished, and is really just a hex viewer at this point. It
seems like a good point to stop and see what others think. I would be
interested to hear any comments.

My command parsing if of course crude, brute-force, and not very
scalable. I am doing some reading on this subject, and will be trying
to do a more generalized approach in the next revision. This is going
to be a subject where I need to learn a lot, because I have 2-3
embedded applications in C that need varying levels of command parsers,
so I will be seeking to improve this skill considerably.

Thanks for input.

--
_____________________
Christopher R. Carlen
cr...@bogus-remove-me.sbcglobal.net
SuSE 9.1 Linux 2.6.5
Looks like mostly clean code to me. I don't understand why you declare
"Offset" globally twice. Wouldn't it make more sense to just stick it
at the top of the file like your "Hexdigits" variable? I'm also not
sure if your style follows the style guide...then again, mine probably
doesn't either. You can check it out here though:

http://www.python.org/doc/essays/styleguide.html

Rather than using if/else statements for error checking, you may want
to consider using try/except:

http://docs.python.org/tut/node10.html

That my 2¢!

Mike

Aug 13 '07 #2
ky******@gmail.com wrote:
On Aug 10, 10:36 pm, CC <cr...@BOGUS.sbcglobal.netwrote:
>Hi:

http://web.newsguy.com/crcarl/python/hexl.py

This is my first Python program other than tutorial code snippet
experimentation. I chose a hex line editor. I may do a hex screen
editor once this is done, if I feel like playing with the curses module.
Or move straight to wxPython.

This is unfinished, and is really just a hex viewer at this point. It
seems like a good point to stop and see what others think. I would be
interested to hear any comments.

My command parsing if of course crude, brute-force, and not very
scalable. I am doing some reading on this subject, and will be trying
to do a more generalized approach in the next revision. This is going
to be a subject where I need to learn a lot, because I have 2-3
embedded applications in C that need varying levels of command parsers,
so I will be seeking to improve this skill considerably.

Thanks for input.

--
_____________________
Christopher R. Carlen
cr...@bogus-remove-me.sbcglobal.net
SuSE 9.1 Linux 2.6.5

Looks like mostly clean code to me. I don't understand why you declare
"Offset" globally twice. Wouldn't it make more sense to just stick it
at the top of the file like your "Hexdigits" variable? I'm also not
sure if your style follows the style guide...then again, mine probably
doesn't either. You can check it out here though:

http://www.python.org/doc/essays/styleguide.html
Nowadays the standard for Python style is PEP 8, which represents an
update on the above.

http://www.python.org/dev/peps/pep-0008/
Rather than using if/else statements for error checking, you may want
to consider using try/except:

http://docs.python.org/tut/node10.html

That my 2¢!
"if" statements are best if the errors are predictable, "try/except"for
the less predictable ones, or when it would be difficult to ensure
correct program flow with "if".

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------

Aug 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Chris Cioffi | last post by:
I started writing this list because I wanted to have definite points to base a comparison on and as the starting point of writing something myself. After looking around, I think it would be a...
68
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
0
by: TechBookReport | last post by:
TechBookReport (http://www.techbookreport.com) has just published a review of the Python Cookbook. This is an extract from the full review: We're big fans of cookbooks here at TechBookReport,...
56
by: Omar | last post by:
I'd love the perfect editor that would be: a) free b) enable me to drag and drop code snippets from a sort of browser into the code c) can run programs right from within d) can edit
4
by: krishnakant Mane | last post by:
hello, right now I am involved on doing a very important accessibility work. as many people may or may not know that I am a visually handicap person and work a lot on accessibility. the main...
25
by: doznot | last post by:
Let's say you want to use Moodle to teach an introductory class in PHP programming. Some of the students have little or no computer experience. In addition to background reading and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.