python - Object class override or modify -
Is it possible to add a method to an object class, and use it on all objects?
is implemented in Python using a dictionary:
< Code> & gt; & Gt; & Gt; T = test ()> gt; & Gt; & Gt; T. Del dc ["afu"] = "blue" & gt; & Gt; & Gt; TOO 'Black'
But for the "object", it uses 'DantePexy' as an interface to prevent such an assignment:
< Code> & gt; & Gt; & Gt; Object .__ dict __ ["test"] = "test" typeError: 'dictproxy' does not support object item assignment
Otherwise, you can not.
NB: You can not modify the metaclass type directly, but as Python is very flexible, I'm sure a guru can find a way to get it, what you want. Is there any black magician here :-)?
Comments
Post a Comment