
Am 17.10.2011 02:30, schrieb Steven D'Aprano:
Nick Coghlan wrote:
On Sun, Oct 16, 2011 at 9:01 PM, Steven D'Aprano <steve@pearwood.info> wrote:
If it's not tested, how do you know it does what you need?
Because my script does what I want. Not every Python script is a production application. We lose sight of that point at our peril.
Systems administrators, lawyers, financial analysts, mathematicians, scientists... they're not writing continuously integrated production code, they're not writing reusable modules, they're writing scripts to *get things done*.
"And it doesn't matter whether it's done correctly, so long as SOMETHING gets done!!!" <wink>
Sorry, but even with the wink this is a dangerous statement. When I write a 40-line script to read, fit and plot a dataset, I don't add a unit test for that. On the contrary, I want to write that script as conveniently as possible. Python is as popular as it is in science *because* it allows that. People hate writing boilerplate just to do a small job.
I'm not convinced that requiring coders to write:
given a, b c do f(a, b, c)
instead of
do f(a, b, c) given a, b, c
gets in the way of getting things done.
I guess this means -0 from my side given: That said: I'm not sure this specific proposal would help. I agree with you and can't see that defining the function before using it is the wrong order. What does appeal to me is the potential for cleaner namespaces; while this doesn't matter so much in the function-locals (there it's mostly the OCD speaking), it would definitely helpful for module and class namespaces (where we routinely see "del" statements used to remove temporary names). I can believe that others see the "given" semantics as the natural order of things. This is probably why Haskell has both "let x = y in z" and "z where x = y" constructs to locally bind names, but there it fits well with the syntax, while in the case of Python, the "given: suite" feels somewhat out of place; we really have to think hard before adding new syntax -- one more thing that the "casual" users Nick mentioned have to grok. cheers, Georg