R
Roman Susi
Rene said:Perhaps a MIX emulator and running TeXDoctest on his books will convince
him..
Or maybe Python written for MIX...
-Roman
Rene said:Perhaps a MIX emulator and running TeXDoctest on his books will convince
him..
Rene said:Steven D'Aprano:
Yes, I think I'll do something like this. Perhaps combined with Peter's
advice to not micromanage, like so:
Reraise = (LookupError, ArithmeticError, AssertionError) # And then some
try:
process_things()
except Reraise:
raise
except:
log_error()
James Stroud said:Why catch an error only to re-raise it?
James Stroud said:Why catch an error only to re-raise it?
This falls under http://c2.com/cgi/wiki?YouReallyArentGonnaNeedThis
Rene said:James Stroud:
Your conclusion may be (almost) right in this case. I just don't like this
approach. Basically this is reverse engineering the interface from the
source at the time of writing the app.
Even if you get it right, it may
fail next week when someone added an exception to a module.
Why? It shouldn't be.
Jorge Godoy:
That's cheating: pydoc is reading the source
That's why reading the source is better. CQFD !-)What I meant was, I'm calling robotparser, and there's no mention of
exceptions on http://docs.python.org/lib/module-robotparser.html
James Stroud said:This is using the source as documentation, there is no law against
that.
How things are and how things should be have always been 2 entirely
different things. See early books by Robert J. Ringer for a more
complete discussion.
Paul said:That's completely bogus. Undocumented interfaces in the library
source are allowed to change between Python versions and across Python
implementations. If you write your application according to the
documented interfaces in the Python manual, it should not break when
someone upgrades to the next Python release. You should not have to
depend on undocumented aspects of the Python implementation which
change out of sync with the application.
That's like saying programs shouldn't have bugs, but they often do
anyway. It doesn't mean the bugs are a good thing or that they
shouldn't be fixed.
James Stroud said:My suggestion was to use some common sense about the source code and
apply it.
Why catch an error only to re-raise it?
The OP is doing it because catching all exceptions masks bugs. There are
certain exceptions which should be allowed through, as they indicate a bug
in the OP's code. Normally the tactic is to catch only the exceptions you
are interested in, and let everything else through, but the OP needs to
catch all exceptions because there are rare exceptions which he can't
predict in advance.
Rene said:Steven D'Aprano:
... This is in a multithreaded ZODB-application....
When an unexpected exception occurs and remains uncaught, a thread
terminates, ....
code don't get out of sync. So source code *is* the best documentation
(or at least the most accurate).
Yes, and that's the Right Thing(tm) to do.
Source code don't lie. Source code don't get out of sync.
So source code *is* the best documentation (or at least the most accurate).
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.