- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Consfued? You will be frist ...
Admin
Love the expectation (according to the comment) that somehow adding extra unit tests will make the terrible design go away ...
Admin
It occurs to me that, in a general sense, to_number will do strange things if the number is an integer (no fractions), but big enough to be impossible to coerce to
int
.Admin
The original author probably has the potential of triggering worldwide shortage of LSD when they code.
Admin
I read the first method, had my mind blown, and decided it was enough WTF for the day. Thank you to the author! Your work trying to understand more of it is truly appreciated.
Admin
Since Python 3, integers are unlimited length, so I think that problem would only occur if the code were still using Python 2.x in 2022. Which isn't impossible if the code was written 6 years ago, but doesn't seem that likely.
Admin
Clear examples of coding-around-the-problem if I have ever seen them. Obviously this person started with little understanding of what they were really trying to do. They proceeded to shotgun edit the code until all the runtime errors went away and they got the output they wanted for their test data.
It probably produces correct results often enough nobody realizes how broken it is. However it can't be understood because it does not do what it claims to do. Eventually someone will want to replace this with something rational that actually implements the rules the business believes it has; maybe some more disciplined folks will be in charge of software by then and someone will get the idea they run transactions in parallel for a while - when they do they will see the results are NOT the same then the tortured effort re-implement the old logic so customers get the same bill begins...
Admin
Considering the unit test comment, and to my own experience, fixing expectations is way harder than fixing the software.
Admin
With apologies to Robert Towne: Forget it, Jake, it's Python.
Admin
OK, so integers are all bignums?
Re: use of 2.x: you'd be surprised. Don't forget RedHat's Anaconda installer from way back, which still used Python 1.6 way past its sell-by date.
Admin
Looks like a Perl programmer that was required to code in Python.
Admin
I just realised that the word "product" can also mean "the result of a multiplication". So the variable named "product_product" seems almost intentionally confusing! Like this was the original author's idea of a joke.
Admin
The authors have already used up all the hash themselves.
Admin
Conceptually, yes. It's a pretty common approach across many languages that gets rid of a lot of weird edge cases. Doesn't mean that they have to be implemented that way the whole time, but you won't notice the shenanigans inside the box if you only look at the outside of the box.