Hi Tao,
python variables are always references. So, in the code example you copied,
textRect and textRect.rect.getParent() are both references to the same actual
node, the issue being that the reference you get from getParent() is broken.
So, 'keep a reference around' basically means: Don't use getParent() or similar
functions to get at nodes if you've subclassed them. Have your own variables
arount that point at the nodes.
Cheers,
Uli
On Feb 1, 2012, at 2:03 PM, tao ira wrote:
> Hi,
>
> I have got a question while reading article Subclassing in Programming Guide.
> In some cases, libavg forgets the class of a derived node and returns an
> object of the base class. Like this:
> >>> textRect = TextRect("foo", size=(100,100))
> >>> print type(textRect)
> <class 'subclass.TextRect'>
> >>> print type(textRect.rect.getParent())
> <class 'libavg.avg.DivNode'>
>
> One of the provided solution in this article is to Keep a reference to the
> derived node around in python. What does it mean by saying "Keep a reference
> to"? Because after several times' trying, I still couldn't do it right, maybe
> it is because I am new to python and failed to get the basic idea of this
> sentence. Can anyone help and explain more about it?
>
> Thank you very much!
>
> --
> Ira
>
>
> _______________________________________________
> libavg-users mailing list
> [email protected]
> https://mail.datenhain.de/mailman/listinfo/libavg-users
--
Any technology distinguishable from magic is insufficiently advanced.
Ulrich von Zadow | +49-172-7872715
Jabber: [email protected]
Skype: uzadow
_______________________________________________
libavg-users mailing list
[email protected]
https://mail.datenhain.de/mailman/listinfo/libavg-users