
Andrew Barnert via Python-ideas writes:
On Apr 17, 2020, at 13:39, Alex Hall <alex.mojaki@gmail.com> wrote:
{ :a, "b": x, :c }
{ ::a, "b": x, ::c }
And now Lisp bites me, because '::a' means "the identifier 'a' in the default namespace", which doesn't make sense in Python, because the (similar) namespacing construct would be class attributes, while Python has a more nuanced way of handling the current namespace. I quite dislike the whole idea of abbreviating associations between identifiers spelled the same way in different namespaces, both in dict displays and in keyword arguments. It's really "grit on screen" level notation. I'd be happy to put aside my "dislike" if statistics on the frequency of such duplicate names across namespaces were presented (and they're compellingly large). I myself am rarely annoyed by this issue, with the single exception of "self.foo = foo" in __init__() defs (which can't be handled by these notations). It's usually the case for me that the LHS of a keyword argument refers to the role of the identifier in the function's computation, while the RHS refers to the application domain, so I'd rarely get to use these optimizations anyway. I guess I occasionally see dictionary displays of the form "{'name' : name, 'address' : address, 'email' : email}" in my code, but even that is pretty rare nowadays, as it generally gets spelled fields = ('name', 'address', 'email') [{k: v for k, v in zip(fields, next_tuple)} for next_tuple in input] or something like that, which is less annoying to maintain when I inevitably add fields. I used to have little dictbuilder functions def add_record(db, name, address, email): db.append({'name' : name, 'address' : address, 'email' : email}) all over the place, but then I learned about dict comprehensions and zip got promoted to a builtin. Steve