Calling functions in main script from a module
Aahz Maruch
aahz at netcom.com
Tue Sep 21 14:33:02 EDT 1999
In article <bfb41e4549%james at bursa.freeuk.com>,
James Bursa <james at bursa.freeuk.com> wrote:
>
>Is it possible to call a function in the main script (the one passed on the
>Python command line) from a module function?
>
>I've attempted to use something like __main__.function(), but this doesn't
>work. The reason I want to avoid passing a function pointer to the module
>function is because I'd like to generate the function name dynamically
>(depending on a gui event) and use eval(), like this
>
> try:
> eval('event_message_' + hex(message_number))
> except NameError:
> pass
I think you'd be best off passing in a dict of function references.
Better yet, create a class, pass in the class, and you can use that
class directly.
--
--- Aahz (@netcom.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6 (if you want to know, do some research)
More information about the Python-list
mailing list