I've long wanted to do
for server in (server1, server2, *other_servers):
Instead of
for server in [server1, server2] + other_servers
I've long wanted to do
for server in (server1, server2, *other_servers):
Instead of
for server in [server1, server2] + other_servers
def combined(*dicts):
return {k: v
for dict_ in dicts
for k, v in dict_.items()}
dicts = [({'a': 'a', 'b': 'b'}, {'b': 'bb'}),]
assert [{'a': 'a', 'b': 'bb'}] == [combined(a, b) for a, b in dicts]What you mistake for readability is familiarity: after you read a word you need to associate a meaning with it. It takes longer to interpret the meaning of things you didn't see before while grabbing a meaning from a cache is nearly instantaneous. You understood this difference in comprehension speed as a readability difference.
My main point is that it makes no sense to talk about readability without first getting used to the grammar and vocabulary of a language. In this case, it's unfamiliar feature in an otherwise normal environment, but it gets worse. There are people who believe they can judge the readability of entirely alien (to them) languages and it hurts those languages reputation pretty badly. Lisps are the prime example of this.
def L(*vargs):
return vargs
tada. >>> stuff = ['c','d','e']
>>> L('a','b', *stuff)
('a', 'b', 'c', 'd', 'e')
Just like that. >>> L(*stuff, 'a', 'b')
SyntaxError: only named arguments may follow *expression
>>> L(*stuff, *stuff)
SyntaxError: invalid syntax