- 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
I think it's not OR's but OROR's, which sounds just like HORROR...
Admin
I might submit a few maintenance scripts I've refactored - some previous employees had... um... some uneven skills.
Admin
If you insist, then the line could be rewritten as:
But when you look at the rest of the code, any blank string that would trigger a false value would be ignored in any case, and any sensible implementation of self.request would only allow strings in its value. Not that you'd keep the rest of the code, anyway. If I had my way I'd pull out something like PyParsing and use that to parse the input instead of some insecure mess of splits, joins and replaces.
Admin
...The most I ever did with it was to augment my PHP-based trouble ticket system so that it uses SpamAssassin to automatically reject spam messages.
...But even with my limited PHP knowledge, that code, which I do not understand at all, just "feels wrong".
Further proof that you can write bad code in any language...
Admin
Isn't it obvious?
It's pipe-delimited.
Admin
I just had to add that parsing Python's strict indentations is not significantly easier than using brackets, just (arguably) prettier. And the parser does not have one single style to understand; there is no rule whether to use tabs or spaces in Python (which can give all sorts of interesting defects).
Admin
request here would most likely be a callable weak reference. Any object can work like a function if you implement the call function (Python does overloading and such through special functions). A weak reference is created like so:
self.request = weakref.ref( original_request_var )
and then you use it each time like so:
self.request().somemethod()
Admin
I hate to be 'that guy', but an empty string evaluates to False, so your example is not equivalent. '' == False, but it could be in self.request.
Admin
Security leaks in browsers. Most of them are triggered by Javascript.
Admin
The example code doesn't look pythonic at all (aside from the required syntax elements). I don't think the person writing this code would have fared any better in another language; perhaps he was one of those poor individuals who has brain damage from writing too much Basic code?
If it were me, I would write a code generator/translator to take my python code and translate it to X language (the flavor of the day). It would allow me to maintain my development in what I know intimately, so my productivity wouldn't be significantly impacted (just the time it takes to write the translator).
Captcha: wigwam Nuclear test series in the Pacific Ocean in the 1950s.
Admin
The question is: Whi change python code into PHP that is the true WTF
Admin
In the dialects of FORTRAN I've used, you don't have to start in column 7, you simply can't start BEFORE column 7, cos the first 5 characters of every line are reserved for (optional) line numbers and the 6th character is reserved for an (optional) line continuation mark. You're free to indent further if you like. (Provided you don't push the end of the line past column 72, since 73-80 are ... something, I forget what, I never used them. I think they were for card sequence numbers that were ignored by the compiler, so if you dropped your deck you could use the card sequence numbers to put it back in the proper order. I actually used a card deck precisely once, and it was input data, not source code.)