News for hackers. Stuff that matters.
Re:PEP 0448 – Additional Unpacking Generalizations by mikelward on Friday July 17, 2015 @09:48PM (#9906284)
Finally!

I've long wanted to do

for server in (server1, server2, *other_servers):

Instead of

for server in [server1, server2] + other_servers

Re:PEP 0448 – Additional Unpacking Generalizations by rectangletangle on Friday July 17, 2015 @10:32PM (#9906372)
I've been wanting this feature for a while as a clean way to combine the results from several queries into a composite object.

    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]
Re:PEP 0448 – Additional Unpacking Generalizations by Too on Saturday July 18, 2015 @03:10AM (#9906836)
Can't tell if you are sarcastic or not but to me the second line is much more readable.
Re:PEP 0448 – Additional Unpacking Generalizations by agumonkey on Saturday July 18, 2015 @11:19AM (#9907724)
That's mostly subjective, (a,b, °c) is a tuple of a, b and the rest being the sequence c. After reading a lot of lisp and ml, it's a bit less of a burden than [a,b] + l, in the sense that [a,b] is declarative mixed with an operation, while (a,b, °c) is one declarative. You might say `°` is an operation too, but it lives at the metalevel, and it's still enclosed in the (tuple-declaration).
Re:PEP 0448 – Additional Unpacking Generalizations by klibertp on Saturday July 18, 2015 @12:05PM (#9907888)
No, both lines are equally readable. A number of operations, placement of operators, names are all the same. The only difference is replacing "," with "]+", which is not any different for your eye* to read.

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.

Re:PEP 0448 – Additional Unpacking Generalizations by deckiedan on Saturday July 18, 2015 @10:16AM (#9907588)

    def L(*vargs):
        return vargs
tada.

    >>> stuff = ['c','d','e']

    >>> L('a','b', *stuff)
    ('a', 'b', 'c', 'd', 'e')
Just like that.
Re:PEP 0448 – Additional Unpacking Generalizations by indosauros on Saturday July 18, 2015 @11:16AM (#9907721)

    >>> L(*stuff, 'a', 'b')
    SyntaxError: only named arguments may follow *expression

    >>> L(*stuff, *stuff)
    SyntaxError: invalid syntax
Re:PEP 0448 – Additional Unpacking Generalizations by deckiedan on Sunday July 19, 2015 @03:12AM (#9910310)
Good point... yes, having it language-level supported does add a lot of good stuff...