[Tutor] raw_input function

Isr Gish isrgish at fusemail.com
Thu Jan 29 05:58:28 EST 2004


     >Christopher Spears wrote:
   >
   >>Where can I go to get some general information on how
   >>the raw_input function works?


Hershel Wrote:
   >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.
   >
 I don't think its a good idea to use input.
Because input uses eval(...) to return the input, and someone who knows whatbthere doing can make some troble. For example they could type in a comand like this:
os.removedirs('c:\\')
Which would wipe out the whole harddrive.

Good luck

Isr




More information about the Tutor mailing list