Class

Jeff Shannon jeff at ccvcorp.com
Mon Nov 12 15:35:08 EST 2001


Robert Amesz wrote:

> Jeff Shannon wrote:
>
> > Robert Amesz wrote:
> >
> >> I wrote:
> >> > [something]
> >>
> >> Ignore previous post: I read 'raw_input' where it actually said
> >> 'input'. My mistake.
> >
> > Though actually, the use of input() is generally not a very good
> > idea, and it would be safer to use raw_input() and then convert
> > from strings if needed.  In this case, it's not needed, and the
> > raw_input result would be better off being compared as a string.
>
> Which is probably why I made that mistake. The use of 'raw_input' is
> not that uncommon, but 'input'? I've never seen 'input' being used in
> a real program. It's not very useful anyway, as input("Expression: ")
> seems to do exactly the same as eval(raw_input("Expression: ")). And
> if I'd need a number, I would use float() or int() on whatever
> 'raw_input' returns, and probably protect it with a try-except block
> to boot. You can't go far wrong by never trusting user input.

Agreed completely--the use of input() threw me at first, too.  :)

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list