Big problem fetching members from dynamically loaded module

Philippe C. Martin philippe at philippecmartin.com
Sat Jun 25 20:04:05 CEST 2005


Hi,

Hopefully to make things clearer: this works from a shell:

In [23]:from SC.CARDS.BC import *

In [24]:l = inspect.getmembers(eval('BC'))

#l will get all members from class 'BC' whereas the code referenced below
gets an exception saying 'BC' is not defined.

Thanks,

Philippe




Philippe C. Martin wrote:

> Hi,
> 
> I'm getting pretty desperate here:
> 
> The code below crashes on the last line (but works from a shell).
> 
> The class 'BC' exists and the loop on self.__BC_EXEC_LIST passes fine.
> 
> It's got to be something really stupid but I've been looking at it too
> long I guess.
> 
> Any clue would be quite welcome.
> 
> Regards,
> 
> Philippe
> 
> 
> 
> 
> 
> 
>     __EXEC_LIST = [ \
>     'import os', \
>     'import sys', \
>     'from SC.pilot.SC_Script_Processor import *', \
>     'from SC.utils.SC_Convert import *', \
>     'import string ', \
>     'from SC.iso.SC_Dec_ISO import *', \
>     'from SC.iso.SC_Enc_ISO import *', \
>     'from SC.iso.SC_Analysis import *', \
>     'sc_sp = SC_Script_Processor ()', \
>     'sc_enc = SC_Enc_ISO ()', \
>     'sc_dec = SC_Dec_ISO ()', \
>     'sc_a = SC_Analysis ()', \
>     'sc_conv = SC_Convert()' ]
>   
>     __BC_EXEC_LIST = ['from SC.CARDS.BC import *','from
> SC.Solutions.SCF.BCInterface import *','sc_bc = BC_Interface()']
> 
> 
>       for l_s in self.__BC_EXEC_LIST: #this loop works fine
>         try:
>           exec (l_s, self.m_process_global,self.m_process_local)
>           
>         except:
>           traceback.print_exc()
> 
>       for l_s in self.__EXEC_LIST: #this loop works fine
>         try:
>           exec (l_s, self.m_process_global,self.m_process_local)
>           
>         except:
>           print >> sys.stderr, 'FATAL INIT ERROR - PLEASE CHECK YOUR
> CONFIGURATION'
> 
>         l = inspect.getmembers(eval('SC_Dec_ISO')) #THIS WORKS - the class
> exists
>         l = inspect.getmembers(eval('BC')) #THIS CRASHES - the class
>         exists




More information about the Python-list mailing list