Why does Python not support record type? (i.e. mutable namedtuple)

后端 未结 11 1569
眼角桃花
眼角桃花 2020-12-12 22:10

Why does Python not support a record type natively? It\'s a matter of having a mutable version of namedtuple.

I could use namedtuple._replace. But I nee

11条回答
  •  天命终不由人
    2020-12-12 22:42

    Based on several useful tricks gathered over time, this "frozenclass" decorator does pretty much everything needed: http://pastebin.com/fsuVyM45

    Since that code is over 70% documentation and tests, I won't say more here.

提交回复
热议问题