473,765 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ne t
SuSE 9.1 Linux 2.6.5
Aug 11 '07 #1
2 3451
On Aug 10, 10:36 pm, CC <cr...@BOGUS.sb cglobal.netwrot e:
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.ne t
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.sb cglobal.netwrot e:
>Hi:

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

This is my first Python program other than tutorial code snippet
experimentatio n. 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.ne t
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
3003
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 waste of time to start writing yet another IDE and so am now thinking in terms of new features/plug-ins for existing systems. Right now I mostly use Komodo Personal and it's pretty close to being what I want. They don't currently support plug-ins,...
68
5882
by: Lad | last post by:
Is anyone capable of providing Python advantages over PHP if there are any? Cheers, L.
0
1223
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, whether its Java, XSLT or Linux, they're a great way of pulling together lots of useful snippets of code and technique in one place. For the beginner they provide instant advice, usable code and a way into new areas. They're also a great way to find...
56
3266
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
1905
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 issue at hand is to create an accessible editor for open office. there are a lot of things remaining on that front. so right now I am trying to find out a temporary work around by creating a simple accessible editor (with wxpython) for viewing and...
25
2842
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 topics-oriented assignments supplied by Moodle, you want to build an online text editor into the course, so students can type their PHP programs and HTML directly into files on the server, so they don't have to fight with NotePad on Windows PCs in a lab, and...
0
9568
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10161
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9833
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.