Ben Finney wrote:
Ed Jensen <ej*****@visi.comwrites:
it would be handy if there was something I could do in the
interactive interpreter to make it tell me what exceptions the file
method might raise (such as IOError).
For what purpose would this be handy? Surely the benefit of the
interactive interpreter is that you can simply try it out and *see*
what happens.
But, in case it helps: Any code may raise any exception at any
time. This is a feature, since it encourages program that are tested
properly.
That's a silly argument, really, unless perhaps you'd consider a box of
pills that look like M&Ms a 'feature' since it encourages parents to
hide them from their kids. A better answer would be along the lines of
"yes, that would be nice to have but in general it's not possible in a
dynamic language; that's the price you have to pay for leaving the
static typing world".
As for the OP's question, since file is a fixed builtin, I think it
should be possible to know all the possible exceptions that can be
raised; I'm not sure if it's clearly documented though.
George