3 ms·
Maybe you can elucidate what about Python's syntax is broken or not DRY? EDIT: To me, seeing this is Python code anywhere would seem to violate principle of le
by rpcope1 12y ago
Maybe you can elucidate what about Python's syntax is broken or not DRY?
EDIT: To me, seeing this is Python code anywhere would seem to violate principle of least astonishment, which I think is somewhat more important than being DRY, if that's even a problem here.
- philh 12y agoIf you want format strings with sensible placeholders, you end up with something like "Hello {person}, it's a {weather} day".format(person=person, weather=weather) The list of variables (person, weather) shows up three times. Somewhat off-topic, a similar problem shows up when you have a bunch of related functions, all taking a particular kwarg (or kwargs), and calling each other. Like def foo(arg, conf1=None, conf2=None): bar(arg+2, conf1=conf1, conf2=conf2) # eww :( def bar(arg, conf1=None, conf2=None): # etc. A neat thing that perl6 has is syntax for "keyword argument whose value is found in the variable of the same name". So the equivalent of that line could be written bar($arg+2, :conf1($conf1), :conf2($conf2)) but it could also be bar($arg+2, :$conf1, :$conf2)