funcs vs vars in global namespace
Alex Martelli
aleaxit at yahoo.com
Tue Sep 14 17:01:22 EDT 2004
David Rysdam <drysdam at ll.mit.edu> wrote:
...
> >>sub_module = __import__(which_module_this_time)
> >>vars(sub_module).update(which_dict_this_time)
...
> Your "which_dict_this_time" dictionary, how are you imagining that
> working?
Just like any other dictionary -- maybe I don't get your question...?
> I was just mapping function name strings to functions
> ({'logError':logError}), but (long story short) that isn't working how I
> want. But shouldn't I be able to define the function right there in the
> dictionary itself?
...because def is a statement and "in the dictionary itself" you can, of
course, only have expressions...? Is this a trick question...?
> Perhaps this is getting too non-obvious, magical and unmaintainable, though.
Your questions are definitely anything but obvious to me...
Alex
More information about the Python-list
mailing list