Python Forum

Full Version: updating values in objects
You're currently viewing a stripped down version of our content. View the full version with proper formatting.


I have a class called patients in which one of the properties is "hr"; it is a list of four heart rate lists, the latter consisting of 4 values.
Example:
hr1 = [45, 50, 50, 45]
hr2 = [85, 45, 62, 77]
hr3 = [70, 104, 99, 65]
hr4 = 77, 89, 65, 103]
hr = [hr1, hr2, hr3, hr4]

There are a total of nine members of patients, each with hr and color. Color is generated from the values of one of the laists in hr.
When creating objects of class patients I initialize it with hr[0][:]. But when I try to update patients by replacing hr[0][:] with hr[1][:], I still get the same colors as generated by hr[0][:].

Here's my code.
for row in file:
person = Patient(firstName, lastName, ptid, hr)
person.color = makeColor(hr[t][:])
t = 1
for person in patients:
person.color = makeColor(hr[t][:])
No indentation, use BBCODE
and shift-ctrl-V when pasting
After fooling around, I figured out the answer to my question. But thanks for the tip on using BBCODE in future posts Wink