On 10/25/2023 11:49 AM, rsutton via Python-list wrote:
On 10/25/2023 11:06 AM, Stefan Ram wrote:
r...@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.

In this particular case you could probably just handle the return result from robocopy right there. Of course, it depends on the rest of the code. It probably doesn't really need an exception, and if you want to handle it in the calling function, you could just return the result as a boolean:

return p.returncode < 8  # Reversed the test since a return of "True"
                         # would make more sense as a return code

Thank you both for your guidance.

Richard


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to