I didn't want to post the following code in the thread I'm referring to, since I didn't want the OP there to think it's ok to do, but I wanted to post this for fun. To show how serious I am about how this code shouldn't be used: I used tabs instead of spaces.

The main() function is entirely unnecessary, especially the function calls though. If you leave them out you don't need to return the lambda either. My point being here just that you could have a function be called immediately and even prevent it from doing anything at all useful later. You definitely don't need to say the name to invoke it. Obviously at some level it's being explicitly invoked, but for an arbitrarily named decorator you probably wouldn't expect this behavior.

And indeed believe that it should remain in the final production version (of the main script of course). I do occasionally use it to test individual modules, but this doesn't work very well in a package structure (and in general I don't do nearly as much TDD or testing as I should).

If I actually save a script, I always use that trick. Because I always write functions, and any function worth anything at all can be tested as a standalone component. I do sometimes keep the main logic of certain programs in that block though, and not in a separate main() function, so that I can run the script with -i and then examine the global state of the script. Not something I do once I get past a certain point, but I've certainly been known to do it.