[Tutor] Inheriting from parent object

Pujo Aji ajikoe at gmail.com
Mon Nov 14 21:32:10 CET 2005

if you want to copy object just use:
import copy
newobj = copy.deepcopy(objparent)
 or just create object which has direct correlation with the parent like:
newobj = objparent
 On 11/14/05, Alan Gauld <alan.gauld at freenet.co.uk> wrote:
> > I want to create a property that will inherit it's value from the same
> > property in it's parent object, but will check it's parent's propety
> > everytime it is called. But that can be over-ridden, and I don't have
> > to know what the objects parent is.
> Ed you are using a lot of OOP terminology here to decribe
> something that looks decidedly non OOP. Can you clarify exactly
> what you mean by the terms:
> object, property, inherit and parent.
> Also can you describe the problem you are trying to solve rather than
> the solution you think you need? It may be that there is a simpler
> paradigm you can use. I'm not sure I really understand what you
> are trying to achieve.
> > object.x = 3
> > object.subobject.x = inherit()
> > print object.subobject.x #prints 3
> > object.x = 4
> > print object.subobject.x #prints 4
> > object.subobject.x = 5
> > print object.subobject.x #prints 5
> object it the built-in object class that provides new-style classes,
> is that theone you are using here? Or is it just a generic name for
> illustration? Is object an instance or a class?
> > What could I put in the inherit() function that would look for the
> > same property of it's parent and return that, whilst keeping it as
> > general as possible?
> I also don't understand what the inherit() function is supposed to do.
> You provide it with no context in which to operate.
> Unless it relies on hard coded global variables there is no
> way it can know about object, subobject or x.
> Normal OOP inheritance relies on creating instances from classes,
> but you don't appear to want to do that, it looks more like you
> are building some kind of containment lattice. I think I need more
> background.
> Alan G
> Author of the learn to program web tutor
> http://www.freenetpages.co.uk/hp/alan.gauld
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20051114/77ef5992/attachment.htm

More information about the Tutor mailing list