Is there a way to apply a function to all entries of a NamedTuple and get an object of the same type back?
The following code
from typing import NamedTuple
class MyNamedTuple(NamedTuple):
a: int
b: int
mnt = MyNamedTuple(1, 2)
fun = lambda x: x*x
m = map(fun, mnt)
will create a generator, but I would like to have another MyNamedTuple object instead. Is there a clean way to do this?