Re: Something to know about Active Python's inheritance mechanism
| Date : Mon, 25 Jul 2005 10:24:50 +0930 |
| To : XSI(at)Softimage.COM |
| From : Luke <luke(at)rsp.com.au> |
| Subject : Re: Something to know about Active Python's inheritance mechanism |
Hi Bernard and Patrick,
There is another developer here who writes pure Python code (non-XSI specific) and he was the one who alerted me to this issue and its solution.
So it would appear that this can certainly happen within the Python command shell.
But it is worth noting that it only seems to happen when you use multiple inheritance where the base classes are from separate files.
The reason that this seems to fix the issue is that when you use multiple inheritance with base classes from different files, the class types are not known upon importing the modules and "self" is not correctly bound when it is evaluated, so that the constructor is looking for a certain type (i.e. a subclass of A or A itself), but since B is not yet of a known type the python compiler has a spew about it. Calling the _dict_ or _call_ methods seem to not check the type or binding of "self" before using it, which seems to get around the issue quite nicely.
Oh, and yes, it would appear that this does also happen with the new-style classes.
cheers,
Luke
Bernard Lebel wrote:
It's interesting.
When you you call the __dict__, you lookup the name dictionary of the class, and then call the name __init__ from the dictionary. I wonder why doing it this way would work but not calling the __init__ directly. Usually having a name show up in the dictionary means it has been assigned (or global declared). I believe the __call__ name is there for operator overloading, but again I just wonder why this would work instead and not the "normal" call. Does this also happens within the Python command line shell?
Bernard
-- luke emrose technical director - luke.emrose(at)rsp.com.au ---------------------------------------------------------------- rising sun pictures - www.rsp.com.au redefining visual effects delivery ---------------------------------------------------------------- direct line +61 8 8400 6400 mobile ph +61 408 893 505 ---------------------------------------------------------------- our adelaide phone number & address has changed, please update your records.......... ---------------------------------------------------------------- adl ph +61 8 8400 6400 - fx +61 8 8400 6401 level 1, 133 gouger street, adelaide, 5034 ---------------------------------------------------------------- syd ph +61 2 9338 6400 - fx +61 2 9338 6401 15/16 charles street east redfern, sydney, 2016 ---------------------------------------------------------------- rising sun research - http://research.rsp.com.au ----------------------------------------------------------------
--- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body: unsubscribe xsi
- References:
- Something to know about Active Python's inheritance mechanism
- From: Luke <luke(at)rsp.com.au>
- Re: Something to know about Active Python's inheritance mechanism
- From: Bernard Lebel <3dbernard(at)gmail.com>
- Something to know about Active Python's inheritance mechanism
| DATE: | << | >> | THREAD: | << | >> | INDEX: | Main | Thread |
|---|
- Previous by Date: Re: [script] finding Custom Pset
- Next by Date: Re: [script] finding Custom Pset
- Previous by Thread: Re: [script] finding Custom Pset
- Next by Thread: Re: [script] finding Custom Pset
- Index(es):
| Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available. |