I'm doing something like below and confused at the results. I've tried looking searching for how to accomplish this but can't seem to find anything. Why in the second block is
ec.exs still test ? How can I properly re-use the ec variable for a new instance of that class ?
class ExampleClass(object): def __init__(self, ex="", exs=set()): self.ex = ex self.exs = exs ec = ExampleClass(ex="hello") ec.exs.add("test") print ec # <__main__.ExampleClass object at 0x0000000002F51668> print ec.ex # hello print ec.exs # test ec = ExampleClass(ex="goodbye") print ec # <__main__.ExampleClass object at 0x0000000002F609E8> print ec.ex # goodbye print ec.exs # Why is this still "test" ?