Too Broad of an exception
Kushal Kumaran
kushal at locationd.net
Wed Oct 25 13:41:09 EDT 2023
On Wed, Oct 25 2023 at 11:49:12 AM, rsutton <rsutton43 at comcast.net> wrote:
> On 10/25/2023 11:06 AM, Stefan Ram wrote:
>> ram at zedat.fu-berlin.de (Stefan Ram) writes:
>>> outer quotation marks) prints some prominent exception types. After
>>> manually removing those that do not seem to apply, I am left with:
>>> "AssertionError",
>>> "ChildProcessError",
>> ...
>> "Manually removing" above was meant to be a fast first pass,
>> where I only excluded exception types that were obviously
>> inappropriate. It is now to be followed by a search for the
>> appropriate exception types among those exception types left.
>>
> @Rene & @Stefan,
> I really appreciate the guidance provided. By replacing Exception
> with RuntimeError, pylint seems happy! More specificity, I guess. I
> know that I could have ignored the pylint exceptions, but I want to
> use this as a learning experience. I looks like I have a lot of
> reading to do on exception handling. IMO all of the try/except code
> looks quite clumsy to me. It may be excellent for some tasks but to
> me, it looks quite inelegant. Like I said, I have a lot to learn.
>
>From what you've described of your problem, it seems like a small-ish
utility program you're writing for your own use. You don't need any
`try`...`except` blocks in such code. You just let the exception stop
your program.
--
regards,
kushal
More information about the Python-list
mailing list