Class data members in C

Hendrik van Rooyen mail at microcorp.co.za
Thu Jan 18 00:27:43 EST 2007


"Nick Maclaren" <nmm1 at cus.cam.ac.uk> wrote:


> 
> In article <mailman.2814.1169026003.32031.python-list at python.org>,
> "Hendrik van Rooyen" <mail at microcorp.co.za> writes:
> |> > 
> |> > Hmm.  The extensions documentation describes how to add instance
> |> > members to a class (PyMemberDef), but I want to add a class member.
> |> > Yes, this is constant for all instances of the class.
> |> 
> |> When? - at time of defining base class, between class definition and
> |> first instance, at time of creating instance, or after instance creation?
> |> 
> |> After instance creation is not easy, I think you would have to add 
> |> to each instance... 
> 
> 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...

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...

<off topic language note>

It has never struck me before that the root word for
"madness" and the slang for "copulation" is the same.
I wonder if there is some sort of a message here?

<end>

- Hendrik




More information about the Python-list mailing list