Error Trapping In Python
Aahz Maruch
aahz at netcom.com
Wed Jul 7 20:38:33 EDT 1999
In article <7m0pgt$cij$1 at eskinews.eskimo.com>,
Jonathon <jblake at eskimo.com> wrote:
>
> The script I am writing expects the user to input an
> integer. Being on the safe side, it reads the raw
> data as a string. However, to convert that string
> to an integer, is perplexing me.
>
> string.atoi.(read_data) will give a value error if
> read_data contains something other than a number.
try:
string.atoi.(read_data)
except: # or except ValueError:
do_something_or_other()
--
--- Aahz (@netcom.com)
Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6 (if you want to know, do some research)
More information about the Python-list
mailing list