SlopPy: An error-tolerant Python interpreter that facilitates sloppy programming
pgbovine.net
pgbovine.net
i haven't maintained the code for ~5 years, so ymmv
Of course, if your script has REAL problems, your data is going to be suspect at step n-1 as well....
IncPy: Automatic memoization for Python: http://www.pgbovine.net/incpy.html
CDE: Automatically create portable Linux applications : http://www.pgbovine.net/cde.html
Burrito: Rethinking the Electronic Lab Notebook : http://www.pgbovine.net/burrito.html
That's wild. I wonder how frequently someone tries to take him up on the offer.
Perhaps this would be better represented as a simple library you can use to catch the error, log it, and then continue with your loop.
And of course, this technique totally fails if you're trying to accumulate anything as you process the data that might end up depending on these N/A values: you'll run your whole program for many hours and at the end it will print the final result: N/A
With this ,you'll get you're partial results, plus a list of all the places with malformed data that you can fix together .
Same goes for other cases where your applications partially works, and there's value in that partial work.
I don't even understand the point of this type of coding. If a program throws an exception and crashes, it means my assumptions were wrong, and the code is handling data it wasn't meant to handle, and needs to be fixed. If I got that part wrong, it's very likely the code around that section is also wrong in some way. On the other hand, if I don't care that the computation fails, why did I have it there at all?
It's worth mentioning that shell scripts also tend to lean towards keeping chugging when they encounter errors, and writing proper error checks in a shell script can be tedious and troublesome. I know I have been bitten by this.
This behavior is very practical when writing quick scripts to automate things or process data. And this is the reason I often prefer Perl over Python for these kind of tasks.
Of course, this has a downside: when you just continue with errors, it's often hard to find the real source of them, or even notice them at all. For bigger application this might end up in weird errors in production that are hard to debug. In this case I very much prefer the behavior of vanilla Python.
Optionally resuming after a computation event that is not meant to always be fatal in a principled manner is an excellent, well known, decades-old power programming technique available in a few sufficiently powerful languages. See, for example, Common Lisp's condition system [1] or Perl 6's similar system.[2]
[1] https://en.wikipedia.org/wiki/Common_Lisp#Condition_system
Students taking introductory Computer Science courses made a lot of simple syntax errors. Some people at Cornell University wanted to help students out. So they wrote CUPL.[1] Cornell University Programming Language.
CUPL attempted to discern the programmers true intention when encountering a syntax error in PL/I. The error message was of the form:
blah blah error
STANDARD FIXUP TAKEN
EXECUTION CONTINUING
This was useful to people who actually wanted to learn PL/I, but for us early hackers it was more amusing to just feed in random data and see CUPL attempt to turn it into legal PL/I. Unfortunately it didn't usually do a very good job.Moral: Some ideas in CS have been around for many many decades.
[1] https://en.wikipedia.org/wiki/Cornell_University_Programming...
Still, well done to the author!