71
- 060701 今年七一網摘
CAPTCHA
自由與暴民
A while back I wrote about emulating C structs in Python using (instance) objects to createnamespaces, and wrote:
(Avoid the temptation to just use '
ms = object()', because ithurts your ability to tell different types of structs apart viaintrospection.)
It turns out that there is another reason to avoid this: it doesn'twork. Somewhat to my surprise, instances of object() can't have newattributes put on them. (Instances of Python subclasses of object(