2

In Django, I can use ptiPython instead of IPython after enabling Django-Extensions plugin to enforce Django-Shell. In Flask world, the alternative one of seems to be Flask-Script, I searched around but could not find anything to use ptiPython with Flask-Shell together.

Kane Blueriver
  • 4,170
  • 4
  • 29
  • 48

1 Answers1

1

Flask-Script support ipython and bpython. You can create custom Shell class

from flask.ext.script import Shell
from ptpython.ipython import embed

class PtShell(Shell):
    def run(self, **kwargs):
        context = self.get_context()
        embed(user_ns=context)

manager.add_command("shell", PtShell())
r-m-n
  • 14,192
  • 4
  • 69
  • 68
  • 1
    This is almost there but ``ptpython.repl.embed`` provides a Python REPL not IPython, so I use `ptpython.ipython.embed`` instead, and change the use to ``embed(user_ns=context)`. Would you mind to have an updating of your answer and I will choose it as the accepted on. – Kane Blueriver Nov 14 '15 at 14:48