3 ms·
You're quoting Larry "I've done more than anyone to fuck up programming languages" Wall as an authority on programer clarity?!? Um... no? here are some example
by zenspider 18y ago
You're quoting Larry "I've done more than anyone to fuck up programming languages" Wall as an authority on programer clarity?!? Um... no?
here are some examples from real python (twisted)... let's see how much clearer they are than anything else:
''.join([''.join(['\x1b[' + str(n) + ch for n in ('', 2, 20, 200)]) for ch in 'BACD'])
''.join([''.join(['\x1b' + g + n for n in 'AB012']) for g in '()'])
msgs = [os.path.join(b, mail.maildir._generateMaildirName()) for b in ('cur', 'new') for x in range(5)]
It is code like this that makes me run for the hills... Even ignoring the list comprehensions, I use join as an example of how python gets everything backwards...
ary.join(', ') # ruby - oop: tell the array to join its elements with a str
join(', ', ary) # perl - fun: join ary with a str
', '.join(ary) # python - wtf: tell the str to join the elements of some other ary?!?
- mleonhard 18y agostring.join(ary, ', ') # python - ok: join ary with a str The parameters to Python's join function are in a better order than Perl's. This is expected since Perl perverts the concept of function arity. Also, twisted is not an example of the best Python code.
- zenspider 18y agoyes, they did add that form after a while... (so much for one right way to do things, eh?). It seems that people still prefer the `sep.join(ary)` form more based on the code reading/debugging I've done. "better order" is subjective and I have to disagree in this case. perl's form isn't limited like pythons as it takes any number of values after the separator. Much like ruby's "* arg" (splat arg--HN's formatting is besting me) or lisp's &rest. Lisp's (+ ...), (< ...), etc are lovely because of this property. Twisted is an example of some of the most popular python code out there... It is representative of real world python and is what drives me away from the language (and has me running screaming away from twisted).
- ynd 18y agoI'm quoting Larry Wall because he said something interesting. The comprehensions from twisted were not written for clarity so they aren't good examples. The programmer wanted a one-liner to define these constants.
- zenspider 18y agoAsking Larry Wall about good OO/language/library design, or PoLS is like asking George Bush (either really) about effective foreign policy or human rights... Even if they say something interesting, is it valuable information coming from that source? Should it be trusted?
- zenspider 18y ago"The comprehensions from twisted were not written for clarity so they aren't good examples" no... they're real examples.