probably is, but from what I get of Brad's mail his problem is that he
wants the equivalent of self upon instancing a module, regardless of the
module being just the inlining of a text file or incorporating classes.
That is the bit that makes it a bit trickier, as you can't rely on
having a class in each module when you use them simply for code re-use
without necessarily object orienting by classes.
the way you found Brad should work, and yes, it will waste some memory,
but what kind of module are we talking about.
******************************
| Raffaele Fragapane |
| Rising Sun Pictures |
| "Remember, TD is for TopDog" |
******************************
Aloys Baillet wrote:
I see, but I think that the module.__dict__ is equal to the current
globals, especially with Class objects.
No?
On 3/31/06, *brad* < brad(at)cg-soup.com <mailto:brad(at)cg-soup.com>> wrote:
Thanks, but I don't think this is going to work for me. I need to
be able to get to the module.__dict__ from with a function of that
module. For a method of a class object, I can get to the class
data via self.__dict__
I've found that I can recursively import the module within one of
its own functions and get the __dict__ attribute this way, but
something tells me this is probably a bad idea or a waste of memory.
> -------Original Message-------
> Hi Brad,
>
> You can try to loop on the globals and check if any has the
type class:
> import copy, types
> for name, obj in copy.copy(globals()).items():
> print type(obj)
> if type(obj) == types.ClassType:
> print name
>
> Cheers,
>
> Aloys
>
>
> On 3/31/06, BRAD <[LINK: mailto:brad(at)cg-soup.com
<mailto:brad(at)cg-soup.com>] brad(at)cg-soup.com
<mailto:brad(at)cg-soup.com>> wrote:
> Here's a fun Python situation. I have a function that needs to
check its
> input by looking at other Classes living inside the same
module. Is there
> an attribute I can call that points to the instance of the
module where it
> lives? This would be analogous to using the self attribute in
an object
> class.
>
> def MyFunction():
> myModuleInstance = ?
>
>
> Cheers!
> -Brad
> ---
> Unsubscribe? Mail [LINK: mailto:Majordomo(at)Softimage.COM
<mailto:Majordomo(at)Softimage.COM>]
> Majordomo(at)Softimage.COM <mailto:Majordomo(at)Softimage.COM> with
the following text in body:
> unsubscribe xsi
>
>
> --
> Aloys Baillet - XSI Technical Director
> Character Dpt - Animal Logic
> --
---
Unsubscribe? Mail Majordomo(at)Softimage.COM
<mailto:Majordomo(at)Softimage.COM> with the following text in body:
unsubscribe xsi
--
Aloys Baillet - XSI Technical Director
Character Dpt - Animal Logic
--
------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.385 / Virus Database: 268.3.3/298 - Release Date: 3/30/2006
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi