1

I am currently developing a console application in python.It takes commands from the terminal in the format <my-python-module.py> <command> <other-args> However i want to drop into REPL and when i write

my-program

It should do like the fololowing

my-program> command 1
my-program> command 2
my-program> exit
good-bye!

How do i do that?

Jack Wachira
  • 192
  • 4
  • 15
  • Probable duplicate of http://stackoverflow.com/questions/1395913/python-drop-into-repl-read-eval-print-loop – AlokThakur Feb 03 '16 at 05:19

1 Answers1

2

The standard library has cmd which gives you "support for line-oriented command interpreters":

The Cmd class provides a simple framework for writing line-oriented command interpreters. These are often useful for test harnesses, administrative tools, and prototypes that will later be wrapped in a more sophisticated interface

There's also prompt-toolkit:

prompt_toolkit is a library for building powerful interactive command lines and terminal applications in Python.

Ben Graham
  • 2,089
  • 17
  • 21