472,993 Members | 2,269 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 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 3408
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.