Help Help Help
Jp Calderone
kuran42 at yahoo.com
Fri Nov 9 06:25:14 EST 2001
Ahh, your loop is nicer, but I liked the encapsulation of the, err,
complex code required to determine if the input was an int... Yea,
that's it. The sys.stdin/print inconsistancy would be due to my
limited experiencing using python on the command line: I usually get
my input from sockets. :)
Jeff Shannon wrote:
> Jp Calderone wrote:
>
>
>> [snip code]
>
> Why do the int() conversion twice?? By rewriting your while loop as follows, you
> eliminate the need for your isInteger() function....
>
> while 1:
> x = sys.stdin.readline()
> try:
> return int(x)
> except ValueError:
> print "That is not an integer, please try again:",
>
> I also wonder why you use sys.stdin.readline() in place of raw_input(), but you
> still use print and not sys.stdout.write() .... but I suppose that's just a
> trivial bit of inconsistency with only aesthetic significance.... :)
>
> Jeff Shannon
> Technician/Programmer
> Credit International
>
>
>
More information about the Python-list
mailing list