Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Creating interactive command-line Python app? (http://www.velocityreviews.com/forums/t352718-creating-interactive-command-line-python-app.html)

planetthoughtful 12-21-2005 12:34 PM

Creating interactive command-line Python app?
 
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


Steve Holden 12-21-2005 12:58 PM

Re: Creating interactive command-line Python app?
 
planetthoughtful wrote:
> 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:

>>> result = raw_input("What can I do for you? ")

What can I do for you? Something
>>> result

'Something'
>>>


regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC www.holdenweb.com
PyCon TX 2006 www.python.org/pycon/


keirr 12-21-2005 02:15 PM

Re: Creating interactive command-line Python app?
 
You may also find the cmd module useful, see:
http://docs.python.org/lib/module-cmd.html

Cheers,

Keir.


bob.blanchett 01-03-2013 12:17 PM

Re: Creating interactive command-line Python app?
 
This is exactly what you want:

https://cliff.readthedocs.org/en/latest/

Bob/Julius Flywheel

On Wednesday, December 21, 2005 11:34:38 PM UTC+11, planetthoughtful wrote:
> 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


Tim Chase 01-03-2013 02:24 PM

Re: Creating interactive command-line Python app?
 
(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

Dave Angel 01-03-2013 02:41 PM

Re: Creating interactive command-line Python app?
 
On 01/03/2013 09:24 AM, Tim Chase wrote:
> (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/Creati...-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



--

DaveA


Tim Chase 01-03-2013 06:15 PM

Re: Creating interactive command-line Python app?
 
On 01/03/13 08:41, Dave Angel wrote:
> 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







All times are GMT. The time now is 09:28 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.