Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49108

Re: (newbye) exceptions list for python3 classes

From Ben Finney <ben+python@benfinney.id.au>
Subject Re: (newbye) exceptions list for python3 classes
Date 2013-06-25 09:27 +1000
References <51c8bb87$0$2407$426a74cc@news.free.fr>
Newsgroups comp.lang.python
Message-ID <mailman.3787.1372116473.3114.python-list@python.org> (permalink)

Show all headers | View raw


chrem <usenetNoSpam@chr1st0ph9.eu> writes:

> Hi,

Howdy, congratulations on finding the Python programming language.

> what is the best way to find out all exceptions for a class?

Python is not Java. Your program doesn't need to know everything that
might happen; you should catch only those exceptions you can actually
deal with usefully, and let any others propagate.

> E.g. I want to find out all exceptions related to the zipfile (I'm
> searching for the Bad password exception syntax).

The documentation will describe the behaviour of the module; many
exceptions are implied by that (e.g. if the module deals with the
filesystem, you can expect OSError to be raised under certain
conditions).

Other exceptions will come from deeper within Python; e.g. if you give
text in a bad encoding you can expect UnicodeDecodeError, or if you give
it an object that can't be handled as expected you might get a TypeError.

But trying to get a complete set of all exceptions that might be raised
is a fool's errand. It would be futile, both because everything in
Python is an object and can therefore raise whatever exceptions are
appropriate, and also because even if you knew a complete set, you can't
usefully do anything consistent with such a huge set of exception types.

So, what is it you want to do one you know a set of exception types that
can be raised by the code?

> thanks for your help or feedback,

Hope that helps, and good fortune to you in learning to code Pythonically!

-- 
 \          “When we talk to God, we're praying. When God talks to us, |
  `\         we're schizophrenic.” —Jane Wagner, via Lily Tomlin, 1985 |
_o__)                                                                  |
Ben Finney

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

(newbye) exceptions list for python3 classes chrem <usenetNoSpam@chr1st0ph9.eu> - 2013-06-24 23:35 +0200
  Re: (newbye) exceptions list for python3 classes chrem <usenetNoSpam@chr1st0ph9.eu> - 2013-06-24 23:43 +0200
    Re: (newbye) exceptions list for python3 classes alex23 <wuwei23@gmail.com> - 2013-06-25 09:22 +1000
    Re: (newbye) exceptions list for python3 classes Dave Angel <davea@davea.name> - 2013-06-24 22:09 -0400
    Re: (newbye) exceptions list for python3 classes chrem <usenetNoSpam@chr1st0ph9.eu> - 2013-06-25 17:55 +0200
  Re: (newbye) exceptions list for python3 classes Ben Finney <ben+python@benfinney.id.au> - 2013-06-25 09:27 +1000

csiph-web