Re: PYTHON: Analog to class.self for modules?

Date : Fri, 31 Mar 2006 06:22:37 +0000
To : XSI(at)Softimage.COM
From : "brad" <brad(at)cg-soup.com>
Subject : Re: PYTHON: Analog to class.self for modules?
Okay, got it thanks. The globals() call gives me a list of object pointers, which I can use in lieu of the __dict__ attribute.


>  -------Original Message-------
>  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 <[LINK: mailto:brad(at)cg-soup.com]  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:[LINK: mailto:brad(at)cg-soup.com]
>  brad(at)cg-soup.com] [LINK: mailto:brad(at)cg-soup.com]  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:[LINK: mailto:Majordomo(at)Softimage.COM]
>  Majordomo(at)Softimage.COM]
>  >  [LINK: mailto:Majordomo(at)Softimage.COM] Majordomo(at)Softimage.COM with the
>  following text in body:
>  >  unsubscribe xsi
>  >
>  >
>  >  --
>  >  Aloys Baillet - XSI Technical Director
>  >  Character Dpt - Animal Logic
>  >  --
>  ---
>  Unsubscribe? Mail [LINK: mailto:Majordomo(at)Softimage.COM]
>  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 with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.