On Sun, Mar 9, 2008 at 9:56 AM, Karlo Lozovina <[EMAIL PROTECTED]> wrote: > 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)?
well after all it's a function so the only ways you can get things out of it are: - return a dict with all the objects - use global (very messy) - use a decorator to do either of the above. on the other hand have you consider using a proper test package? instead of inspecting the objects manually from the shell you could make it all automatic. with assert statements. you could use the std. python testing modules http://docs.python.org/lib/development.html or something less verbosed like nose http://code.google.com/p/python-nose/ > > 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 > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list