I have a class that only contains attributes and I would like packing/unpacking to work on it. What collections.abc should I implement to get this behaviour?
class Item(object):
def __init__(self, name, age, gender)
self.name = name
self.age = age
self.gender = gender
a, b, c = Item("Henry", 90, "male")
I would like to avoid using a namedtuple.
Iterable, so you need to implement__iter__. - jonrsharpe__iter__toreturn selfor not - you could justreturn iter((self.name, self.age, self.gender)), for example. It must be iterable, but not necessarily an iterator. - jonrsharpe