Error Testing

Chris Angelico rosuav at gmail.com
Sat Oct 19 09:04:13 EDT 2013


On Sat, Oct 19, 2013 at 11:57 PM, Roy Smith <roy at panix.com> wrote:
> On 10/19/13 8:23 AM, Scott Novinger wrote:
>> > My goal is to make sure that the value entered for the radius is an integer
>> > value.
>
> In article <mailman.1254.1382186691.18130.python-list at python.org>,
>  Ned Batchelder <ned at nedbatchelder.com> wrote:
>
>> First, radius is the result of input(), so it is
>> always a string, never an int.
>
> input() returns ints or floats for values which can be converted to
> those.  I suspect you're thinking of raw_input()?

Negative. The OP stated Python 3.2, in which Ned's statement is
correct. :) In Python 2.x, yes, input() will return an int if it
evaluates as one, but in 2.x, I would STRONGLY advise against ever
using non-raw input(). (To be honest, I'd have to say that the
innocuous name 'input' concealing code evaluation is an embarrassment,
and one that I'm very much glad is now removed from the language.)

ChrisA



More information about the Python-list mailing list