[IPython-user] How can an embedded ipython session communicate with the caller?

Matthew Wilson matt@tplus1....
Sun Mar 22 19:36:59 CDT 2009

I'm writing a program that launches an IPython session to allow the user
to work on some database objects.

I need to keep track of whether any objects were altered so that I can
prompt the user to commit or rollback the changes at the end of the

This is what I tried:

    from IPYthon.Shell import IPShellEmbed
    tampered = False
    s = IPShellEmbed()
    s()  # Then inside my ipython sesson, I set tampered to True.

    print("tampered is %s" % tampered)

It looks like when I assign a value to tampered, I'm only masking the
global with a local.  So after the IPython session ends, tampered is
still set to False.

So, how do I do this?


More information about the IPython-user mailing list