|
|
|
|
|
by bmitc
1382 days ago
|
|
It may just be me, but I find Python nearly unreadable at times. Everything is just so ... slippery? Is this well written? w for w in words if w in WORDS
There's just two concepts there, w and words, doing a whole lot. I mean, that's literally a filter, but Python refuses to embrace these things because they're supposedly confusing or hard. In F#, that would be: List.filter (fun word -> List.contains word WORDS) words
I would of course rename WORDS and words to be something distinct rather than just differ by capitalization. The Python is confusing because the way to trace this comprehension is by starting with the w in the middle, then the w at the end, and then the w at the beginning (i.e., 2-3-1 sequence).Also, I highly dislike using lines of code as some sort of ultimate measurement. The program is what it is, and then requires a page 5 times the length of the program to explain the program. The program should be clearer or more comments added to it or both. The program also uses Python's "feature" of evaluating default arguments once when the function is defined as a sort of global variable, because the P function is never used by passing in a value for N. Seems clever, which is the problem with it. Lastly, function names should be more clear. "known", "P", and honestly the others are not good function names. |
|