prompt-toolkit / ptpython

A better Python REPL
BSD 3-Clause "New" or "Revised" License
5.19k stars 277 forks source link

Keep environment when exiting ptpython #94

Open blark opened 8 years ago

blark commented 8 years ago

So I'm a bit of a noob, please excuse me if this is a dumb question.

I'm creating an app that uses prompt_toolkit and I'm embedding ptypython in it. If I change a name from ptpython for example self.prompt = "foo >" it doesn't keep this change when I exit back into my app. Likewise I'd like to be able to import a module and then use it back in my app. Is there any way to do this, maybe I'm just missing something easy... but if not I think this would be a nice feature.

Thanks very much.

ryneeverett commented 8 years ago

Dropping into a repl in the middle of a module, doing some stuff, and resuming module execution while retaining the state of what you did in the repl -- it kind of sounds like you're describing pdb behavior. Perhaps you should take a look at ptpdb.

blark commented 8 years ago

Wow. I am just exploring all of this awesome stuff. ptpdb is amazing too! I'm very excited to use it...

It seems that ptpython is picking up the namespace of my script (so I can use tab completion for the names in my class) but for some reason ptpdb is not, is there something I'm missing?

Once again thanks for helping me out, it's much appreciated. I look forward to getting to a place where I can contribute to these packages!

edit: I think I answered my own question -- the interact command gets me to an interactive interpreter that has these features. Very cool!

So I guess the follow up question is, I looked through the docs and don't see a way to enter directly into the interactive interpreter. Is there a way to start there instead of in debug mode? Moving this to the ptpdb repo...