[Tutor] collecting keyboard input

Andrei Kulakov ak@silmarill.org
Tue, 6 Aug 2002 15:40:09 -0400


On Mon, Aug 05, 2002 at 05:25:39PM -0700, Mathew P. wrote:
> I understand that this is the place to be a total newbie in confidence
> :-)
> 
> Well, here goes.
> 
> I am writing a python program on linux and most input is parsed from
> the command line at run time.
> 
> However, there are a few places in the program where I need to ask the
> user a question or two mid run.
> 
> I would like to know what facilities python has for collecting keyboard
> input and error checking it on the fly (limiting the string length, not
> allowing numeric imput in string input fields vice/versa and so on.) I
> was kinda thinking of basic's input and instring functions, but I am
> quite sure that python has facilities that are *worlds* above anything
> basic has to offer, since it rocks in every other area!
> 
> thanks for the help,
> 
> Mathew

You ought to use raw_input() and then manually check if it's not too
long, if it's got numbers or chars in it, etc.

> 
> =====
> In the United States, Gun ownership is *not* a privilege, it is a constitutional right that is under attack continuously.
> 
> "If gun ownership is outlawed, only outlaws will have Guns"
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - Feel better, live better
> http://health.yahoo.com
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 

-- 
Cymbaline: intelligent learning mp3 player: python, linux, console.
get it at: http://silmarill.org/cymbaline.htm