Hi,
I'm new to programming and Python. The problem I have is with removing list elements that are instances of custom class.
import copy
class some_class:
pass
x = some_class()
x.attr1 = 5
y = some_class()
y.attr1 = 5
z = [x,y]
zcopy = copy.deepcopy(z)
z.remove(zcopy[0])
This returns: ValueError: list.remove(x): x not in list
Is there a simple way to remove element from list by using reference from deepcopied list?
edit: Thanks for your answers. I found some solution using indexing. It's not pretty but it does the job:
import copy
class some_class:
pass
x = some_class()
x.attr1 = 5
y = some_class()
y.attr1 = 5
z = [x,y]
zcopy = copy.deepcopy(z)
del z[zcopy.index(zcopy[0])]