[Tutor] raw_input function
hcohen2 at comcast.net
Wed Jan 28 14:21:19 EST 2004
Christopher Spears wrote:
>Where can I go to get some general information on how
>the raw_input function works?
>"I'm the last person to pretend that I'm a radio. I'd rather go out and be a color television set."
>"Who dares wins"
>-British military motto
>"Far more creativity, today, goes into the marketing of products than into the products themselves..."
>-"Pattern Recognition" by William Gibson
>Tutor maillist - Tutor at python.org
Look at some of the books on python, e.g. 'Learning Python' new edition
recently released or 'Core Python Programming'.
var_name = raw_input('Enter some information: ')
will always give you a sting result, even if you enter a list or some
numeric type. To convert to a particular type use a function on it:
var_float = float(raw_input('Enter some information: ')),
but I would enclose something like this within a try: ... except: construct.
Also you could use
var_name = input('Enter...')
this will return the actual type you entered.
Hope that helps a bit,
More information about the Tutor