Message280356
This file is derived from my namedlist project on PyPI.
I've stripped out the namedlist stuff, and just left namedtuple. I've also removed the Python 2 support, and I've removed support for default parameters. After that surgery, I have not tested it very well.
Those are my excuses for why the code is more complex that it would be if I were writing it from scratch.
Anyway, instead of using eval() of a string to create the new() function, I use ast manipulations to generate a function that does all of the correct type checking. It calls eval() too, of course, but with a code object.
I originally wrote this as an exercise in learning how to generate AST's. I can't say it's the best way to solve this problem, and I haven't benchmarked it ever. So just consider it as a proof of concept, or ignore it if you're not interested. |
|
Date |
User |
Action |
Args |
2016-11-08 22:17:14 | eric.smith | set | recipients:
+ eric.smith, rhettinger, ncoghlan, methane, serhiy.storchaka, xiang.zhang |
2016-11-08 22:17:14 | eric.smith | set | messageid: <1478643434.38.0.266750331876.issue28638@psf.upfronthosting.co.za> |
2016-11-08 22:17:14 | eric.smith | link | issue28638 messages |
2016-11-08 22:17:14 | eric.smith | create | |
|