reading a file
Alex Martelli
aleaxit at yahoo.com
Wed Aug 30 17:41:39 EDT 2000
"Janko Hauser" <jhauser at ifm.uni-kiel.de> wrote in message
news:87og2a5yz9.fsf at ifm.uni-kiel.de...
> Comparing these two different answers, one from a humble
> non-programmer (me) and one which is supposed to work also in hostile
> environments, where nothing can be assumed beforehand, I wonder if you
> have a library of these things or at least a list of situations which
> trigger your hand to fasten your seatbelt so to speak.
Anytime I'm accessing the filesystem, the network, a database,
a peripheral, or anything else related to the operating system
or to the external world, I assume something could go wrong
(and I assume I'm never sure what it could be). "Only the
paranoids survive", etc.
I also prefer (a highly controversial stance) not to assume that
I know all the exceptions that could possibly come up. Which
probably means I tend to be too-general in my 'except' clauses
(here, for example, it has been rightly suggested that I should
only catch IOError; that's _supposed_ to be the only possible
exception from either open() or .read()...). I guess this comes
from having been burned in the past by "throws (foo, bar)"
clauses in C++, which may be causing an over-reaction (that
is not appropriate for Python; being specific about what kinds
of Exception one expects and can handle is indeed best here!).
Alex
More information about the Python-list
mailing list