@pyimport ends up creating a closure (`pymember`) around the PyObject handle (passed as 'o') for the module, here:
https://github.com/stevengj/PyCall.jl/blob/0823f7c08ae1fd8a82cd3fb8fa5ecb5623087864/src/PyCall.jl#L311-L328 I don't immediately see a way to get a reference to 'o' back out (it might be useful to save a reference, and would be pretty simple to add that to PyCall). However, there is a work-around -- do what you would do to find a module reference by name in Python: julia> using PyCall julia> @pyimport sys julia> m = sys.modules["math"] PyObject <module 'math' (built-in)> julia> m[:foo] = 1 On Tue, Jun 2, 2015 at 6:56 PM, Jack Minardi <[email protected]> wrote: > I need to set a module level variable in a python module through PyCall. > If I use the `pyimport()` function I can successfully set the module > variable on the returned PyObject. Can I get access to this PyObject when > using the `@pyimport` macro instead? >
