关于python:使用`__dict__`或`vars()`?

Use `__dict__` or `vars()`?

内建函数vars()在我看来更像Python,但我看到__dict__使用得更频繁。

python文档表明它们是等效的。

一位博主称,__dict__vars()快。

我该用哪个?


(P)一般来说,你应该考虑Dunder/magic methods to be the implementation and invoking functions/methods as the API,so it would be preferable to use EDOCX1 university 0 over EDOCX1,in the same way that you would do EDOCX1/English 2 and not EDOCX1(p)


(P)我用的是字母名称0(p)(P)From:https://wiki.python.org/moin/Dubiouspython%35过早%(p)布尔奇1(P)From:The Zen of Python(p)布尔奇1


(P)我Agree EDOCX1第7个英文字母应该是首选。My rationale is that,as Python Evolves,EDOCX1 penal 7 may be extended to do more than EDOCX1 penal does(for example,work for objects with Slots,possibly in 3.7).(p)