- 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
frist
Admin
TRWTF is using Python.
Admin
Having code in a class is the same as having bone marrow floating in your blood: the organism will not survive.
Admin
All IB's colleagues probably have Dunning Kruger Syndrome...
Admin
Like my cow-worker who was given the task of making sure that sensitive data could be masked in a restore-from-production scenario.
First, create a table that describes the table/column to mask, and the mask to apply. That seems o.k.
Install that table in the same database as the one being masked, instead of creating a separate database specifically for this process. OK, nto the best, but it works. Makes it more likely that the process will be accidentally run on production, but not a huge issue I guess.
Here's the process: --restore production to a working db --create a copy of the table being masked, copying data from "real" to "new" table --apply the mask to "new" table --drop any FKs in the "real" table --drop the "real" table --rename "new" table to "real" table --reapply FKs
When asked why this was ever anything more than generating an update statement from the masking data, "well, I don't know...I'd have to think about that...". I don't know how such a process even occurs to someone to try.
But nobody can figure out why our code is slow and unreliable.
Admin
Obviously the try-except is also a WTF as no exception can be raised. But if one could be raised, swallowing it would be a terrible idea.
My guess is that initially extend_f was inside the try.
Admin
Python over all! Long live Python.
Admin
When they say Python has powerful libraries they aren't joking, because if you try to write code to do task without offloading all the parts to an existing library, you're TRWTF.
Admin
Does that still hold when talking about #ifdef in C code?
The only functional difference that I see between the C preprocessor and python's ability to inline code into a class definition is the fact that the C preprocessor directives are a completely different language from the language that they are modifying.
Admin
No, because preprocessor directives in C are computed at compile time and won't ever change.
Inline code in bodies change the body dynamically. In the example in the article, the function definition changes dynamically based on the value of X. So if you mishandle the variable you may not be executing the code you think you're executing.
Powerful in some ways, a big conduit to WTFs in others.
Admin
Well what is the problem with self modifying code? evil grin. It is of of the resulting wonders of the Von Neumann architecture, and it will make sure that we will never run out of content for this site :-)
Admin
This is the second Python-based article in a row.
Is there a meta-story here? One about any language, however weird and niche at the start, breeds idiots to abuse itself as it gains traction?
The specimen presented here could not have happened in any other language known to me.
Admin
It doesn't work that way, though you could probably build something that does if you're perverse enough and implement the right magic methods. The class definition acts as a statement that is executed once when the module it's in is loaded. Afterwards the class object is defined and the body doesn't change.
Just try it in a python interpreter.
Admin
You're wrong. In the example in the article, that code runs exactly once - when the module is imported. The definition of mod.Class does not get re-evaluated because mod.x changes, so this is effectively identical to a preprocessor directive. Eg:
In fact, this kind of code is common if supporting py2/py3, you may define a different function body depending on six.PY3.