2 ms·
namedtuple and dataclasses both use eval(), so if you want to give up eval(), you'd need to give them up, too.
by ericvsmith 6y ago
namedtuple and dataclasses both use eval(), so if you want to give up eval(), you'd need to give them up, too.
- VectorLock 6y agoInteresting they use eval(), I wonder if their implementations could be changed to not use eval(). I guess in the end you could just use actual classes for these cases, but I sure do like namedtuple and dataclasses.
- ericvsmith 6y agoMy bad: it's exec(), not eval(). And I wrote dataclasses, so you'd think I'd know better! The issue is that it's dynamically generating methods. There has to be a way to get dynamically created code into python for this use case.