- 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
People who use Python are HEAVY with Whitespace. <tic>
Admin
My eyes, zie goggles, they do nothing!
Admin
it's the mayan temple pattern!
Admin
This is stupid in any language, but this shows that crappy programmers use Python too and not only VB or PHP.
Admin
Let me guess: the real WTF is the use of "elif" when everyone knows that it should be "eleph". It's short for "elephant", isn't it?
Admin
Well, not natively, but there is a module for that…
Admin
I think this is the first time I've seen an algorithm that's O(n^15)
Admin
The Real WTF is goto for Python.
Admin
Surley the Python thing is barely here nor there - if you were going to write like this, you'd indent pretty much the same in languages like Java or C#?
Admin
Wow... that's so bad I was compelled to fix it...
The beauty of the original function is that if (wlc[-1] != '9zZzZZ'[List - 1]), then the function will generate a file with (len(wlc) ** 15) lines: assuming wlc is alphanumeric, this would be 221073919720733357899776 lines.
Admin
Is it code for Zliminator?
Serieously, what does it do? Create all possible combinations? I thought that if function name is generate_password you need to generate only one password.
Admin
On the contrary. I've seen work from a programmer who refused to use indentation at all because "all that white space is wasteful." And no, his code was rarely as streamlined and efficient as the example included (he eschewed loops for a similar reason, and refused to use subroutines because, as he said, the overhead of handling the stack may significantly slow operation down, or something). Fortunately I was not required to work for long on the same project.
Admin
And I once worked with a guy who felt the same way about line breaks. Not blank lines, all line breaks, so every line of code was the full width of the editor screen (which thank god back then was 80 characters), naturally all with 1- and 2-char var names. No, I am not kidding.
Admin
Admin
This makes me want to pull out a gun and say "Not Today MF'er!!!"
Admin
Am I missing something, or is this a passwordgenerator without random() function?
Admin
It shows pretty clearly though why they call it Python though.
Admin
Language wars focus too much on how the best devs always write good code and the worst devs always write bad code. There's a huge chunk of mediocrity in the middle of that spectrum, and those are the devs most influenced by the language they use. (Plus it's nice when your language doesn't actively resist your attempts to use it well.)
Admin
That algorithm sucks whatever language it's written in.
Admin
If you squint slightly and turn your head to one side, it kinda looks like a Space Invader.
Admin
Is it that it's full of snakes that can bite you in the ass if not careful?
I think that can happen in any language.
Admin
Given a list of characters (wlc) and a length (maxchar), it prints out all the possible combinations to a file (txt) and if verbose is true it also prints them to screen.
The List variable is used to tell it when to stop. If that equals 1 it stops when it gets to all 9's, 2 tells it to stop at all z's, 3 all Z's, 4 all z's again, 5 and 6 both all Z's. I don't understand why it repeats the z and Z ones multiple times. Also, this is a silly way to get it to stop to begin with.
To show a very simple one, if you gave it wlc = '89', maxchar = 2 and List = 1 you'll just get this:
88 89 98 99
Unless I'm also missing something.
Admin
CAPTCHA: esse - Enjoy my comments, or esse!
Admin
Admin
Pascal didn't use semicolon to end a line - it used it to concatenate two statements. The effect is similar, but symantically different.
Admin
Admin
FORTRAN line continuation is analogous to IBM line printer continuation. Teletypes used line feed/ carriage returns to move the lines, IBM printers use magic characters at the beginning of the line to tell the printer what to do. IBM did this so they could patent it, since LF/CR was obvious and had already been invented.
Admin
Admin
If you squint slightly and turn your head to one side, it kinda looks like sunglasses for Bill the Cat. http://www.murphdogg.com/images/bill.jpg
Admin
I am sick and tired of these motherfuckin snakes on this motherfuckin plane
Admin
i6 = i6 ?
Admin
Whacha gonna do, Brother, when this 15 iterator python comes crashing down on you?!
Admin
I love how you concatenated “semantically” and “syntactically” into one word.
Admin
Of course recursion is a bad thing because setting up base cases is hard and you never know if you accidentally miss a base case and end up recursing too far, plus it increases your memory useage and makes everything in general slower!
(for functional equivalence, you would need another recursion depth counter which starts at 15, a check which only concatenates the next digit if len(wlc) < maxchar, and include the checks for 9s, Zs, and zs in the outer loop)
Of course another WTF is assuming they don't want to generate passwords with more than 15 characters.
The crap about checking for 9s, Zs and zs at the end is a workaround to try and keep it from taking forever.
Of course, I could mention all of the things scattered throughout the code which just screams: I'm a C programmer who knows nothing about Python programming; but that's half of the fun of these Code SODs.
Admin
Admin
Admin
captcha mara: this is a good example of how to mara python program with C-isms.
Admin
When I first saw this I was sure that grammatical errors would be flagged miles away from where they occurred, but in deed this almost never happens. Turns out, even inexperienced coders rarely make the mistake of concatenating two operators or two operands.
I used this language heavily for over a decade and never felt the lack of explicit statement terminators.
-Harrow.
Admin
Admin
Also, don't put a "signature" at the bottom of your posts. It make you look like a douche.
Admin
You win the internet for today. I LOL'd, this made my day.
Admin
Admin
Admin
Pfft! This is freakin' Python!
from itertools import combinations
passwords = [[''.join(i) for i in combinations(plm, r)] for r in xrange(2, len(plm)]
Not exactly the same as that gibberish, but something pretty close, and it's a one-liner!
Admin
The real question is whether, after the first year, you felt the need for psychotropic drugs to control your insanity.
Paradox was EEVIL.
Admin
I hope they generated that source code. However, I don't want to see the source code for the generator.
Admin
Luckily, Python includes a multi-purpose module to solve situations like this. It's great for up-front training, gentle correction, meditation, and very occasionally (when the earlier opportunities were sufficiently missed) as a ton of lead bricks:
import this
Admin
I want to die.
Admin
Come on z00n3$!$, do your thing!
Admin
Oh WTF, fixed that myself.