How to config ptpython when embedding in an app

68 views Asked by At

I am using PTPython to interactively debug my app. When embedding PTPython in my app, how do I support reading the PTPthon config file?

According to the example PTPython config file, in Linux the PTPython config file should be located at the path ~/.config/ptpython/config.py

I'm embedding PTPython using the following:

from ptpython.repl import embed
embed(globals(), locals(), vi_mode=False)
1

There are 1 answers

0
JS. On

Based on this example, I've found the following will read my PTPython config file:

from ptpython.repl import embed, run_config

def configure(repl):
    config_path = pathlib.Path("/home/me/.config/ptpython/config.py")
    run_config(repl, config_path)

history_path = pathlib.Path("/home/me/.ptpython/history")
embed(globals(), locals(), vi_mode=False, configure=configure, history_filename=history_path)