Howto dynamically add object to the list

Piotr Legiecki piotrlg at sci.pam.szczecin.pl
Thu Jul 26 06:56:44 EDT 2001


Hi

I have such a class

class Patient:
  x=0
...

And such a code to add objects of class Patient to a growing list:

...
  while curPatient!=-1:
    pacjenci.append(Patient)
    curPatient=GetNextPatient(allPat, curPatient, pacjenci[i])
.....   

Well, it is wrong code (I add classes Patient ?! not objects of this
class). So how to add an object to the list in such a situation?

something like:
....
while curPatient!=-1:
    obj=Patient
    pacjenci.append(obj)
    curPatient=GetNextPatient(allPat, curPatient, pacjenci[i])
.....

Is it ok?

-- 
Regards
Piotr Legiecki



More information about the Python-list mailing list