[Tutor] Re: Tutor Digest, Vol 1, Issue 2671

Tony Cappellini tony at tcapp.com
Mon Mar 22 13:13:22 EST 2004


>
> Message: 7
> Date: Mon, 22 Mar 2004 16:54:40 +0100
> From: sigurd at 12move.de ( Karl Pfl?sterer )
> Subject: Re: [Tutor] a question about exceptions
> To: tutor at python.org
> Message-ID: <m3fzc03naf.fsf at hamster.pflaesterer.de>
> Content-Type: text/plain; charset=us-ascii
>
> On 22 Mar 2004, Tony  Cappellini <- tony at tcapp.com wrote:
>
> > I've found this code on the net- I think it was from the Python Cookbook.
>
> >          try:
> >             Celsius=float(string.atoi(CTemp))
> >          except string.atoi_error:
> >             print repr(CTemp), "not a numeric value"
> >          else:
>
> This code is very outdated.  Today with a recent python noone would
> write it like that.
>
>
> > I understand what's happening-in general. What I don't understand is
> > the exception type
> > string.atoi_error.

Obviously this is from the string module. I failed to get the point across
of which I am having difficulty with.

What I don't understand is- when I looked in the Python documentation,
under
exceptions, only the built-in exceptions were listed. When I searched the
searchable help file in Python 2.3, for string.atoi_error, nothing was
matched. It doesn't state that exceptions other than the built-ins exist,
in any of the modules.

So- the documentation failed to explain what other types of exceptions are
already included in Python- even if they are in modules, and not the
built-ins.

> This is from the string module.  If you import it you will see that
> error.  But `atoi' should no longer be used; `int' is better.

I will look into this

I've already used raise, but without subclassing my own exceptions.
I'll take a look at the string modeul again.
thanks





More information about the Tutor mailing list