[Python-talk] Oops! Fallen off the track - where to go from here
Ric Werme
ewerme at comcast.net
Sat Jul 18 19:57:46 EDT 2009
> Alright, I have been told I am off track. So how to get on track?
>
> I have a poor grasp of OOP, so how to improve it?
Actually, neither do I. One reason I decided to learn Python was to
learn something about OOP in a language where it wasn't tacked on as
an after thought like C++.
I haven't gotten much beyond "objects are just like C structs that have
pointers to subroutines." This drives OO zealots batty for reasons
I haven't quite figured out. (I will admit that the way subclasses
let us concatenate C structs together is cute.) I also look fondly
on the way Python lets me hang more stuff on to a class instance (C
struct) at will. This drive Javas programmers batty, and for fairly
good reasons.
One big gap in my Python training is I've never had to work on a large
chunk of code written by good Python programmers.
Also "method" is just "subroutine", and "class library" is just library.
A class is just a handy way to keep some code and data together. Kind of.
The only reason I can see for using method is to be able to say "There's
a method to his madness." :-)
> ==== diversion ===============
> Their code used a self.log.write which I was trying to emulate. I
> didn't understand how self.log was created. ... In the book WxPython In
> Action, there is not one reference to creating a log, nor how to capture
> what I would call 'state'.
That's because it's a book on wxPython, not a book about creating files.
> ==== end diversion ===========
> I have downloaded Ric's wx code and am taking a look at it. For some
> reason, I can't take it all in on screen, and will have to print it out
> - learning style I guess. More questions to follow.
==== diversion ===============
Any program worth learning is too long to learn from reading a screen. Paper
is still good. One thing we've lost since the 1970s are how compiler and
assembler programs used to produce paper listings of source code that
were far more useful than the raw source. No one ever printed out raw
source for assembly code, the list file output had machine code, cross
reference lists, subtitles you could change as appropriate, etc.
==== end diversion ===========
In all seriousness, I did try to use some of the OO aspects of Python
to decent advantage so you may learn a bit about them. Do draw circles
and arrows to show how events flow through the code between routines,
especially the values associated with a SpinCtrl make it back to the
draw engine in clroses.py. Also draw boxes showing how a SpinPanel
gets built up from its components, and the main screen is populated overall.
Then try adding a radio box, first to display, second to provide a value
that gets printed from clroses, and then make look like something
you want in your program.
-Ric
More information about the Python-talk
mailing list