simple question

Bignose3 k98jh01 at kzoo.edu
Thu Aug 16 16:20:14 EDT 2001


I am a student starting to learn python coming from a C++ background.
I am writing a simple simulation program were I am trying to assign
each "swimmer" an ID.  Unfortunatley the way I would do it in C++
doesnt work for python.  Can someone guide me in the right direction.

Here is the code that doesnt work, see what I am trying to do:

nextID= 0
class swimmer:
    def __init__(self, xpos, ypos):
        self.ID = nextID
        nextID= nextID + 1
        self.xpos= xpos
        self.ypos= ypos
    def xcord(self):
        print self.xpos
    def ycord(self):
        return self.ypos
    def swimmerID(self):
        return self.ID

An explanation would be great to.  Not a complex program but you have
to start somewhere:)

Joe



More information about the Python-list mailing list