Putting function references in a Queue

tiissa tiissa at nonfree.fr
Sat Aug 6 08:50:26 EDT 2005


Richard Townsend wrote:
> I've been experimenting putting a reference to a function into a Queue
> object and was wondering what actually gets put in the Queue - is it the
> function's code object?

It would simply be the entire function object (unless you choose it 
otherwise).

> If I read from the Queue in a different module, it appears that I don't
> need to import the module that defines the function - or any module that it
> uses - is this generally true, or are there some conditions to be aware of?

Functions are objects that carry around their code but also their global 
namespace (including modules) and some other things.

With a function f, try for instance 'dir(f)' and 'f.func_globals'.



More information about the Python-list mailing list