Class data members in C
Nick Maclaren
nmm1 at cus.cam.ac.uk
Thu Jan 18 04:58:07 EST 2007
In article <mailman.2861.1169101998.32031.python-list at python.org>,
"Hendrik van Rooyen" <mail at microcorp.co.za> writes:
|>
|> > Oh, one of the first two - I am not bonkers! Changing a class after
|> > instance creation is guaranteed to cause confusion, if nothing else.
|> >
|> *grin* - its also just about impossible to do, if you try to imagine
|> what you would have to do to all instances when you effectively
|> change the __init__ method. And some people expect it to happen
|> automagically...
Oh, it's quite easy to do, with several different semantics. I have even
used a couple of them. All are seriously counter-intuitive :-)
I have never used one that successfully reran initialisation, though
I have seen people attempt it! And tried it myself ....
|> Sorry I can't be of more help. All of the docs I have read essentially
|> talk about changing instances. From a practical point of view I would
|> say: "Just redefine it". But that is not very helpful. Specially if you are
|> mucking about in C, as your title suggests...
Thanks. As someone else posted, the answer is PyDict_SetItemString
immediately after PyType_Ready.
Regards,
Nick Maclaren.
More information about the Python-list
mailing list