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

Andrew Berg bahamutzero8825 at gmail.com
Sun Oct 2 04:01:20 EDT 2011


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 need to affect the instance created in the main script; creating a new
instance would be pointless (and AFAICT would result in the interpreter
hitting a recursion limit since the module is imported during creation
of the instance).

-- 
CPython 3.2.2 | Windows NT 6.1.7601.17640 | Thunderbird 7.0



More information about the Python-list mailing list