Shortest way of creating an object with arbitrary attributes in Python?

前端 未结 11 893
谎友^
谎友^ 2021-02-01 14:48

Hey, I just started wondering about this as I came upon a code that expected an object with a certain set of attributes (but with no specification of what type this object shoul

11条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-01 15:14

    You might be interested in the "Struct", which is part of the IPython package. It does what you want to do, with lots of useful methods.

    http://ipython.org/ipython-doc/rel-0.13/api/generated/IPython.utils.ipstruct.html

提交回复
热议问题