Creating interactive command-line Python app?

P

planetthoughtful

Hello All,

Newbie to Python, and I'm wondering if it's possible to create a Python
console app that prompts for further input on the command line when run
(in Windows XP, if that's important)?

I've tried Googling, but the results are overwhelmingly about
interactive Python environments (IPython etc etc), instead of how to
achieve prompting at the command line when running your own Python app.

Any help appreciated!

Much warmth,

planetthoughtful
 
S

Steve Holden

planetthoughtful said:
Hello All,

Newbie to Python, and I'm wondering if it's possible to create a Python
console app that prompts for further input on the command line when run
(in Windows XP, if that's important)?

I've tried Googling, but the results are overwhelmingly about
interactive Python environments (IPython etc etc), instead of how to
achieve prompting at the command line when running your own Python app.

Any help appreciated!

Much warmth,

planetthoughtful
Yes. Look at the raw_input() function:

regards
Steve
 
T

Tim Chase

(original post from planetthoughtful didn't seem to arrive here, so
replying to Bob's reply)
Newbie to Python, and I'm wondering if it's possible to create a
Python console app that prompts for further input on the command
line when run (in Windows XP, if that's important)?

While Bob's suggestion of "cliff" sounds interesting, Python also
offers the "cmd" module[1] in the standard library which does most
of what I've needed in the past. If you've got the readline library
available, it also supports autocompletion and command-line history
which is a nice bonus.

-tkc

[1]
http://docs.python.org/2/library/cmd.html # py2.x
http://docs.python.org/3/library/cmd.html # py3.x
Docs should be about the same
 
D

Dave Angel

(original post from planetthoughtful didn't seem to arrive here, so
replying to Bob's reply)
Newbie to Python, and I'm wondering if it's possible to create a
Python console app that prompts for further input on the command
line when run (in Windows XP, if that's important)?

While Bob's suggestion of "cliff" sounds interesting, Python also
offers the "cmd" module[1] in the standard library which does most of
what I've needed in the past. If you've got the readline library
available, it also supports autocompletion and command-line history
which is a nice bonus.

-tkc

[1]
http://docs.python.org/2/library/cmd.html # py2.x
http://docs.python.org/3/library/cmd.html # py3.x
Docs should be about the same

The two replies in 2005 mentioned both raw_input and the cmd module (in
case that's what he was implying). They were posted within 90 minutes
of the original.


http://python.6.n6.nabble.com/Creating-interactive-command-line-Python-app-td910404.html

I assume that cliff is much more recent, and Bob wanted to update the
thread after 7 years.
http://pypi.python.org/pypi/cliff
 
T

Tim Chase

The two replies in 2005 mentioned both raw_input and the cmd module (in
case that's what he was implying). They were posted within 90 minutes
of the original.

Ah. 2005 would explain why my newsreader has purged them as ancient
history :) Thanks for the clarification.

-tkc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top