In python, I have a class that contains a list as one of its members.
class fan_details:
name = ""
previous_addresses = []
age = 0
fans = []
x.name = "Joe Blow"
x.previous_address.append("4, seaview rd")
x.age = 42;
fans.append(x)
x.previous_address.pop(0)
x.name = "Jimmy Flag"
x.previous_address.append("21, Main Street")
x.age = 33;
fans.append(x)
print fans[0].previous_address
print fans[1].previous_address
The two last print statements would print out "21, Main Street". It looks like the append() is like a pointer in C as the fans[0].previous address is the same as fans[1].previous address.
Is there a way of keeping fans[0].previous_address to "4, seaview rd"?
Please bear with me as I am a noob in Python.
Thanks in advance.