Returning values from function to Python shell/IPython

Karlo Lozovina _karlo_ at mosor.net
Sun Mar 9 11:56:14 EDT 2008


Hi all! 

I have a runTest() function inside my module, which sets up and initializes
lots of objects and performs some basic tests on them. Usually (from
IPython) I just write `run my_module.py`, and then `runTest()`. But
sometimes I would like to manually twiddle with objects runTest creates. Is
there any way I can "return" all those objects local to runTest(), and have
them available in IPython (or ordinary Python shell)?

Thanks...


P.S.
I know I can do it from a:

if __name__ == '__main__':
  # lots of object initialization...

and then have all those objects available in the interpreter.

-- 
Karlo Lozovina -- Mosor



More information about the Python-list mailing list