Posts: 4,647
Threads: 1,494
Joined: Sep 2016
i'm importing a module that may have errors in the source code. i tried to catch it like:
try:
import flaky
except ImportError:
print('bad module')
but it gave me
SyntaxError instead.
ImportError didn't cover it. how can i find all the exceptions i might need to cover?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
i'm wondering what else there is besides SyntaxError. i've seen some other errors in the code before. i am wanting to know what are all the possible exceptions that could be raised.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
(Jun-22-2021, 03:42 AM)bowlofred Wrote: What is your intent with catching the SyntaxError? What do you want the program to do when the import fails?
that is mostly undecided. it will initially be some error message to the user. that's how i plan to initially test it.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
ah... since import runs the code, too, that does open up
any exception.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.