QUOTE(bam @ Aug 19 2006, 11:35 PM)
yea there was some issues, got it all solved, though not quite as nice as yours. I am new to c-style programming, mostly I diddle with visual basic(for my company work). I saw that python had a nice gui to play with pyQt so this "seemed" closest to vb, so I thought the learning curve would be a little more flat, but guess not. I will however need to start writing "functions" and "subs" in order to keep stuff organized and not spagetti code, not only that but reuseability will be nicer.
Congrats on getting your program working
Going from VB to any
modern language is going to have bit of a learning curve, but if you stick with it you'll make yourself a much better programmer. However, I have to disagree with your statement that you're new to C style programming. What you call C style is technically referred to a "imperative" programming. Both VB and C (at least in conventional usage) are actuall very similar in abstract programming language terms.
What causes a lot of confusion for new Python programmers is that it offers a number of features borrowed from the world of "functional programming". Things like lists, first-class functions, list comprehensions and built-ins like map() and filter() let you break out of the imperative style when writing Python code.
Why would you want to do that? Well, research shows that for many types of problems functional programming techniques result in much smaller programs with far fewer bugs. It makes it possible to work with programs as mathematical expressions rather than cookbook recipes. Ask yourself "where are most of the bugs in my programs?" The answer is usually "loops and state". Note how my example contained neither
The function I defined wasn't there for traditional structured programming purity, it was there so I could pass it as a variable to the filter() built-in
The whole idea of passing functions as variables may sound a bit strange, but that's one of the keys to FP.
Now, just as one can write FORTRAN style code in C++, it's possible to write VB style code in Python. But if you really want to improve yourself as a programmer, focus on learning to use the FP features in Python. In the long run, you'll be glad you did
If you want to learn more Functional Programming For The Rest Of Us
is a good place to start.