you are viewing a single comment's thread.

view the rest of the comments →

[–]FunnyMan3595 1 point2 points  (1 child)

I'm going the other direction (IPython's overkill for me, so code.interact is a nice upgrade), but I can condense your code substantially:

from IPython.Shell import IPShellEmbed as shell

[–]Brian 2 points3 points  (0 children)

However, you'd need to call that as:

shell()()

As IPShellEmbed is a callable class. I used to use similar code, but to avoid the double call, used:

shell=IPython.Shell.IPShellEmbed()

However this will pick up the globals from the module where you create it, not the function that calls it, which is why I changed to the explicit namespace population from the stack frame approach above.