I have an imaginary class:
class Foo: def __init__(self, **values): self._value_tuple = tuple(values.items()) And I would like to be able to convert it to tuple using built-in constructor:
>>> foo = Foo(ham=1, eggs=2, spam=3) >>> tuple(foo) (('ham', 1), ('eggs', 2), ('spam', 3)) *I know I can to it manually, by implementing a method like astuple(). I would like to, if possible, achieve it by calling tuple constructor.