Posts: 4,655
Threads: 1,498
Joined: Sep 2016
is there any known circumstance, situation, or case, in which
open()
or at least
open(some_file_name,'w')
could fail without raising an exception? IOW, when calling
open()
in write mode in a function which is given the filename for the defined purpose of writing, should that function test the return value for something untrue or at least not a file type?
or is it OK to assume any open failure will always raise an exception that the function can ignore and let its caller handle?
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,655
Threads: 1,498
Joined: Sep 2016
when i am writing classes and functions to be used when coding other Python scripts (aside from those specifically intended to work with exceptions or errors in some way) i should just let all error propagate up to the caller to handle, unless i can identify a specific reason to handle it. the higher up an exception is handled, the better. is this a pythonic philosophy?
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,655
Threads: 1,498
Joined: Sep 2016
so, let the exception make sense to the code that could be handling it, rather than depending on someone reading the traceback.
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,655
Threads: 1,498
Joined: Sep 2016
that actually happened to me, except it wasn't a fuse. it was corrosion in the switch contact of the transmission the was part of the loop that powered the relay that fed power to the starter motor. it was supposed to allow power to the relay when in park or neutral. and, this only happened if it rained the day before but the mechanics could find nothing wrong. it started OK and i drove it home. 3 mornings later, i try to go to work and it did the same thing. turns out all i needed to do was shift it out of park and back into park and that would rub the corrosion off enough to let it start. it was the tow truck driver that figured it out and the mechanics looked and found it was corroded. they ordered a replacement switch that came from out of the country despite it being made in the USA (Jeep Cherokee). so for the next couple weeks, i knew what to do to get it started. i found that all i really needed to do was just jiggle the transmission lever in place a couple times to get it to start. and i found that it would only take sitting for about 20 minutes in park to corrode, again, and all this only if it rained the previous day.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.