How do I know all thrown exceptions of a function?
Alex Martelli
aleaxit at yahoo.com
Wed Jan 24 03:57:03 EST 2001
More information about the Python-list mailing list
Wed Jan 24 03:57:03 EST 2001
- Previous message (by thread): How do I know all thrown exceptions of a function?
- Next message (by thread): How do I know all thrown exceptions of a function?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Delaney, Timothy" <tdelaney at avaya.com> writes: [snip] > For a start, you shouldn't ahve to declare anything if you guarantee that > nothing happens. Lack of declaration should be "nothing happens". Tut-tut. "Explicit is better than implicit"! In Python, if you want to write a statement in which "nothing happens", you DO have to *explicitly* say that: pass in sharp contrast with other languages, such as C++, where you don't have to write anything to guarantee that nothing happens (the empty string is the empty statement). Me, I've grown to like this *A LOT*. Ideally, "nothing being said" could be framed as an ambiguous situation, and lead to a compile time error; however, when needed for pragmatical reasons (some interpretation having overwhelming frequency; or, backwards compatibility), one can and does bend that (Python being highly pragmatic!). Here, I definitely don't think that "I ensure this function never raises any exception" is "of overwhelming frequency" -- looks like a very strong guarantee to me, and one which should DEFINITELY not be "the default". Maybe in the abstract there should be NO default and any function not decorated with 'raise nothing', 'raise any', 'raise <explicit list>', etc, should not compile; but that's pretty unclear -- so I have absolutely no heartbreak over 'raise any' being made the default, and keeping backwards compatibility. > Argh! From a practical viewpoint, this is the way to do it, but from an > aesthetic viewpoint ... Clearly, aesthetic is in the eye of the beholder! To me, this seems just a special case of optional type-annotation: failing to annotate SHOULD mean "and I'm not providing ANY information about what types this thing here can be" -- both for compatibility with existing Python, AND because it keeps the RAD, uncluttered, fast-to-write-and-easy-to-read, nature of our beloved language; one then goes back and OPTIONALLY AND SELECTIVELY annotates "SOME portions to taste" with type information, including "this function always returns a sequence" or "this function never raises any exception". Pragmatics and aesthetics are thus quite aligned here, from my personal viewpoint. Alex
- Previous message (by thread): How do I know all thrown exceptions of a function?
- Next message (by thread): How do I know all thrown exceptions of a function?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list