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

Andrew Berg bahamutzero8825 at gmail.com
Sun Oct 2 01:12:05 EDT 2011


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 can only be called via commands sent to the main script
(it's an IRC bot, and commands are sent via IRC). What I want to do is
call those methods without sending commands (I want to send an IRC
message from an except clause). I'm not too sure which bits are
relevant, and it's probably a lot of code for a post, so I'll link:

Main script (DelphiBot().load() is where commands are processed):
https://github.com/sthrs/Beacon/blob/501ab1ffef83aa13613edb5985ad9a4570245a85/main.py

The module I'm working on with examples of both functions that use
commands and functions that don't:
https://github.com/sthrs/Beacon/blob/501ab1ffef83aa13613edb5985ad9a4570245a85/modules/lastfm.py


I have developer access to the repo, so modifying the main script is not
an issue (I realize there is a very good possibility this will require
changing the way the bot handles loading commands). A push in the right
direction would be greatly appreciated, as I'm quite stumped.

-- 
CPython 3.2.2 | Windows NT 6.1.7601.17640 | Thunderbird 7.0



More information about the Python-list mailing list