Re: Is there any way to access attributes from an imported module?

2011-10-03 Thread Rhodri James
On Mon, 03 Oct 2011 03:21:41 +0100, Andrew Berg wrote: I found a way to do it, albeit a very hackish one. Since the class instance already catches exceptions from the modules it imports, I can make a custom exception (in a common area for both it and the submodules to import) for it to catch

Re: Is there any way to access attributes from an imported module?

2011-10-02 Thread Andrew Berg
I found a way to do it, albeit a very hackish one. Since the class instance already catches exceptions from the modules it imports, I can make a custom exception (in a common area for both it and the submodules to import) for it to catch and have it call its own methods there based on information s

Re: Is there any way to access attributes from an imported module?

2011-10-02 Thread Rhodri James
On Sun, 02 Oct 2011 06:12:05 +0100, Andrew Berg wrote: I'm not sure the subject's wording is the best, but I'll try to explain. I have a main script that imports several modules and I need to be able to call methods from a class instance inside that main script from a module. Do you mean th

Re: Is there any way to access attributes from an imported module?

2011-10-02 Thread Steven D'Aprano
Andrew Berg wrote: > On 2011.10.02 01:55 AM, Steven D'Aprano wrote: >> Have I missed something? Why can't you just import the module and call >> the methods like you would for any other module and class? >> >> import module >> instance = module.Some_Class() >> result = instance.method(some, argum

Re: Is there any way to access attributes from an imported module?

2011-10-02 Thread Andrew Berg
On 2011.10.02 02:11 AM, Gary Herron wrote: > You may be able to do the simplest thing: If a module wants to call > something form the main module (or main script as you call it) just try > importing that main script and call whatever it is you want. This > results in a circular set of imports,

Re: Is there any way to access attributes from an imported module?

2011-10-02 Thread Andrew Berg
On 2011.10.02 01:55 AM, Steven D'Aprano wrote: > Have I missed something? Why can't you just import the module and call the > methods like you would for any other module and class? > > import module > instance = module.Some_Class() > result = instance.method(some, arguments, may, be, needed) I nee

Re: Is there any way to access attributes from an imported module?

2011-10-02 Thread Steven D'Aprano
Andrew Berg wrote: > I'm not sure the subject's wording is the best, but I'll try to explain. > I have a main script that imports several modules and I need to be able > to call methods from a class instance inside that main script from a > module. Currently, functions can be defined to access the

Is there any way to access attributes from an imported module?

2011-10-01 Thread Andrew Berg
I'm not sure the subject's wording is the best, but I'll try to explain. I have a main script that imports several modules and I need to be able to call methods from a class instance inside that main script from a module. Currently, functions can be defined to access the methods, but such functions