No, exec is the right thing to use here, it is exactly the way namedtuples are implemented in the standard library. Only in this way the records can have a nice signature when introspected.