Skip to content

We Demand A Shubbery

Now that I have got peoples attention with a gratuitous Monty Python quote, I will move onto Python of the programming language variety :)

I’ve been meaning to teach myself python for a long time. Every time I start, I get bored very quickly of the texts/tutorials that I am following. Recently, I found a niche at work where a small python application would fit in nicely. I just needed a little program to search a database for either a depot number or depot name (the user would specify which) and it would quickly return a plethora of information, such as their delivery schedule, phone number, address and such. A (very quick) look through the books I have on the subject didn’t really help, so I decided to do what I normally do: Dive into google and try and pull together a hodge-podge mish-mash of tutorials and walkthroughs to cobble together something that does what I need, without completely understanding what is happening :)

It doesn’t work :(

Well, it does work, just not exactly how I want it to. For anyone that is still reading, and actually wants to help me out, the source for the app is here. I realise that there are several things that can be cleaned up, such as the output for each depot being piped to a single string with line breaks in it, and that it would be much better being piped to a dictionary instead. This type of thing is on my list of ‘Things That Will Be Done Later’. All the wxGlade stuff was done via the built-in tool in SPE (It’s the best IDE I’ve found for Python on Windows, which is the OS I have to use at work). I am not afraid to admit that I only slightly more than absolutely no idea about how it works, but it displays how I want it to so I’m happy to leave it.
Things That Aren’t Right:

  1. When the script is run (either by the run dialogue & “python.exe depotsearcher.py” or after compiling it with py2exe) The GUI runs, but with a blank terminal window behind it. I would like to get rid of this terminal window as it is superfluous.
  2. The next button doesn’t work. If you put in a search that returns more than one result, it will just print them all one after the other. I believe (from researching online) I will probably have to learn how to do threading, and re-write most of the code around this to get it to work.
  3. It Barfs (i.e. Claims on one hand to have found an entry, but then fails to display it) if a depot doesn’t have an entry in Item(2). Any other Item that is empty just results in it returning (for example) “Site 2 2nd Del: None”. This is annoying.

I reckon I am going to have to give it a break and actually learn Python. I have tried Dive Into Python many, many times and find so incomprehensibly boring that I don’t get very far. I find that the Non-Programmers Tutorial for Python progresses too slowly, and possibly (if memory serves me correctly) doesn’t go as deep into the language as I need…

(Background – I have coded before, but for a long time it has only been in VBA, as that is all I have ‘access’ to at work. This meant that anything I coded involves loading up a bloated MS Office application that really shouldn’t be necessary for the simple task I am wanting it to do. It is possible that if I asked & pushed hard enough I could get Visual Studio to work with, but I would still have to learn a new language. Therfore I decided that I would much rather learn a cross-platform, open-source language, hence the decision to move to Python.)

… I have even tried little things in the past, like trying to learn through existing applications (for example: mrben’s Lugradio Mirroring Script) and had a look through the Jokosher code, and Jono Bacon’s Python/GStreamer tutorial. These however (especially Jokosher!) seemed like blindfolded extreme diving headfirst into python! If anyone can recommend a really good book, or online tutorial, preferably that they can recommend from experience, please leave a comment, as this is something I would really like to move forward on

{ 3 } Comments

  1. Benjamin A'Lee | November 28, 2006 at 5:30 pm | Permalink

    If I remember correctly (I haven’t used Python on Windows much), renaming .py files to .pyw will make them run without a CMD window in the background.

  2. mrben | November 29, 2006 at 10:12 am | Permalink

    Actually, for a windowed app you just need to change a variable in your setup.py for running py2exe.

    In the setup line it should read setup(windows=['myprog.py']) rather than setup(console=['myprog.py'])

  3. Essk | November 30, 2006 at 7:44 pm | Permalink

    On the recommending books line Learning Python & Programming Python by Mark Lutz (O’Reilly) are both excellent. Learning Python starts *very* basic so you might find it a bit if a slow starter but it does eventually cover more advanced topics in a comprehensive way. It also provides a nice general introduction to object orientated programming concepts. Plenty of exercises (& solutions!) as well. Programming python explores more “real world” applications, guiding the programmer through worked examples from many different areas (system programming, GUI programming, intarwebs…) but with less of the “basic” stuff.

Post a Comment

Your email is never published nor shared. Required fields are marked *