- 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
Come on Alex - we expect a bit of reverse engineering so we can at least start to understand what it's trying to do
Admin
Come on Alex - we expect a bit of reverse engineering so we can at least start to understand what it's trying to do
Admin
If you use Python and the Viper architecture, do you get a new snake species?
Admin
I'm having a hard time understanding how this even works? It looks like 'word' is 'maxchar' long, OK. Then the length of 'List' sets the target letter for the O(n^15) loop? And only when the contents of 'lword' (which are all that target letter) match 'word' does it break? And each iteration it logs that word even if it ignores it?
Addendum 2024-07-10 07:56: Not the length of 'List', but its integer value. And like all bad code, there's no argument validation.
Admin
Yup. But that's just a badly named parameter. (Should be "ListLength", subject to some debate about snake_case vs PascalCase vs camelCase...)
Indeed.
True
would work OK (being interpreted as1
), but ...And don't forget that if you pass
'yes'
forverbose
, the first iteration throws aValueError
on theif int(verbose):
line in the innermost loop.But the lines that can set
end
to1
do it by comparing stringified lists, and one of the lists is a listified string. I'm pretty sure you won't find many actual experts in Python who'd call that "Pythonic".And overall, the function returns nothing (pendantry:
None
), and writes stuff into the poor text file until it reaches the first string that matches a specific pattern:if
List
is 1, the pattern is "9".if
List
is 2, the pattern is "zz".if
List
is 3, the pattern is "ZZZ".if
List
is 4, the pattern is "zzzz".if
List
is 5, the pattern is "ZZZZZ".if
List
is 6, the pattern is "ZZZZZZ".Now, what does it write into the text file, poor thing? Until it matches the pattern above, it writes one line of
maxchar
characters for each permutation of "maxchar
characters chosen fromwlc
with replacement". If there are none of the relevant character inwlc
, it writes every possible permutation of that, probably consuming a lot of disk space ifmaxchar
is the maximum supported, 15, andwlc
is even as long as 8. (With 15 and 8, it uses 524288 GiB of disk. It'll be a while before we developers commonly see 500+TiB disks.)Personally, I detect the gentle aroma of rattus rattus here. I'm inclined to think that it's a joke function, because there's no way it does anything actually useful. (Notable: it does not generate a password.)
Addendum 2024-07-10 09:03: Observation: if
maxchar
is less than 15, andwlc
doesn't contain the pattern-making character, it repeats the ...Admin
... sequence until it has emitted
len(wlc) ** (15 - maxchar)
copies of the sequence.Admin
Thought here--this is malicious, not nearly as incompetent as it appears.
It's purpose is to generate a "random" password that's not even remotely random.
Yes, there are bugs, but I don't think this is as deeply flawed as it's being made out to be.
Admin
I don't want to be mean, but that looks to my like the average Python code you sadly see these days. A lot of non-devs have started to use it even before the AI hype started popping up.
Admin
This is one of the many reasons why I think substituting braces with whitespace was a mistake.
Code form is something completely separate from code function and serves a completely different role. One is meant for the human reader and the other for the machine. By forcing them together all you are doing is forcing people to write code that are hard to read by humans.
Admin
Code form is often part of the code.
eg. If I have a lot of similar, small functions (eg. getters/setters) I often make them single lines to save space and make it easy to read (and easier to spot typos - they stand out more when you can compare almost-identical lines above/below them)
Admin
A developer who cannot readily adapt themselves to a particular code formatting standard is probably not much of a developer.
Admin
I have to disagree, not only does white space force the dev to write readable(with in limits) code, in this case it instantly shows the biggest error - too many levels of indentation. without even needing to analyse the code & the heart of the loop(s)