Why doesn't the namedtuple module use a metaclass to create nt class objects?

后端 未结 4 1763
野性不改
野性不改 2021-02-18 14:02

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

4条回答
  •  情歌与酒
    2021-02-18 14:50

    As a sidenote: The other objection I see most often against using exec is that some locations (read companies) disable it for security reasons.

    Besides an advanced Enum and NamedConstant, the aenum library* also has NamedTuple which is metaclass-based.


    * aenum is written by the author of enum and the enum34 backport.

提交回复
热议问题