[triangle-zpug] static list in python
Joseph Mack NA3T
jmack at wm7d.net
Fri Mar 14 18:06:29 UTC 2008
On Fri, 14 Mar 2008, Bradley A. Crittenden wrote:
> from your description it sounds like you're using python
> without taking advantage of any object oriented features.
> you can do that, but you'll end up scratching your head
> about how to do 'obvious' things.
<scratching_head>hmm, I see</scratching_head>
> how about just making a class and setting the list as an
> instance variable? or it could be a class variable.
I wish this had showed up in one of my google searches :-(
I wanted a static list to keep track of the history of the
game nim that I'm using as a coding exercise for an
introductory class in programming for 7th graders. This is
their first piece of coding after "hello world", "hello
world" in a function, conditional evaluation and iteration.
I was hoping to keep track of the game history with a
function (to show modular programming) rather than spread
the state tracking code all over the global namespace.
I've had minimal experience with python, and had my own
course outline ready (bash, perl, linux install and admin,
C, C++) before I declared that I'd do the class. I had
expected that they'd be the usual oppressed and compliant
kids that the educational system turns out and hadn't
expected that they'd have an opinion on what they wanted, so
I was more than surprised to have them announce that they
wanted python. At that stage I was committed to teaching
them something and figured if I couldn't learn python fast
enough to keep 2 weeks ahead of a bunch of 7th graders, I
should take myself out the back and shoot myself.
Chris Calloway mentioned my course earlier on this list.
At the moment they aren't writing code blocks more than a
couple of lines long. I don't want to start them on classes
until they have a lot more coding experience and can code
blocks 20-50 lines long without external help. I hadn't
expected that python would get this complicated so fast ;-)
I thought static would do it for sure - it's worked
everywhere else. It's obvious that you don't need static if
you have an object. I'll keep your code to do a rewrite
sometime later in the course using a game_history object.
Joseph Mack NA3T EME(B,D), FM05lw North Carolina
jmack (at) wm7d (dot) net - azimuthal equidistant map
generator at http://www.wm7d.net/azproj.shtml
Homepage http://www.austintek.com/ It's GNU/Linux!
More information about the triangle-zpug