Eric V. Smith added the comment:

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.

----------
nosy: +eric.smith
Added file: http://bugs.python.org/file45399/namedtuple1.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28638>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to