Why doesn't the namedtuple module use a metaclass to create nt class objects?
问题 I spent some time investigating the collections.namedtuple module a few weeks ago. The module uses a factory function which populates the dynamic data (the name of the new namedtuple class, and the class attribute names) into a very large string. Then exec is executed with the string (which represents the code) as the argument, and the new class is returned. Does anyone know why it was done this way, when there is a specific tool for this kind of thing readily available, i.e. the metaclass? I