News for hackers. Stuff that matters.
Re:Practical Python Programming by disgruntledphd2 on Friday June 19, 2020 @06:01AM (#23572896)
I mean, you need to write tests before you refactor, but that's true in all languages.

I do agree (and have the scars to prove it) that this isn't a panacaea but it does help, a lot.

That being said, one of the worst bugs I had in python was in passing in the wrong types to a constructor function, and my tests didn't catch that. To be fair, Mypy would have, but I hadn't annotated that part. At the end of that debugging situation, I would have gladly killed somone for enforced static types in Python.

That being said, the data model is a work of art, and a core reason why I enjoy coding in Python. It's just a shame that pandas kinda sucks.

Re:Practical Python Programming by the_af on Friday June 19, 2020 @09:39AM (#23574402)
I find the problem with writing tests for Python is twofold:

- Most Python programs I write start their life as tiny scripts, always with the certainty they'll never grow (Narrator: they always grow). I don't know many people who write tests for their scripts...

- Testing in Python means too much effort in the wrong places. Consider that most refactoring problems would have been caught for free by a language with static typing. I've experienced runtime errors because I changed the return type of a function from a single value to a list (or viceversa). A statically typed language would have let me know of my mistake for free, so that I could focus on tests that really matter.