Search code examples
pythoncommand-line

Creating a Terminal Program with Python


I recently started learning python. I have created some basic webapps with Django and wrote some simple scripts. After using VIM as a Python IDE I really fell I love with "Terminal programs" (is there an official term for this?). Right now I am capable of doing simple things like asking someones age and printing it to the screen. However this comes down to running a .py script and after this script is done the normal bash return. I would like create a program that I can run from the command line and that would allow the same user experience as VIM (one that you open and close). For example I created a simple script to import RSS feeds. It would be cool if I could open my terminal type the name of my program -> program would open -> Then I would like to use commands like :findsomething. Basically have real interaction with my program.

To conclude:

  • How would I go about creating such a program?
  • What kinds of modules, books or site would you recommend

Solution

  • A true command-line program is something in the vein of ls or grep; it is started from the command-line, but it's non-interactive and can be used in pipelines and combined with other command-line programs. A typical command-line program is not interactive on its own, instead relying on shell for interaction, and on an init file for customization.

    What you want to create is a TUI (text user interface) application, that uses the full capabilities of the TTY as an interactive platform. To do that, look up curses.