Thursday 3 November 2016

python - remove item from list according to item's special attribute

I have a list composed with my defined items, each of which has a attribute .name



t = [item1, item2]


I want to remove item from the t list according to their attribute .name, like remove() or pop() methods. Maybe I can do something like:



t.remove(item.name=="Removed me")



Maybe I don't need to go through the whole list to filter out the item needed to be removed.

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...