Hello,
It is sometimes tedious to write a dictionary in Python. For example,
def register_user(first, last, addr1, addr2): d = {'first': first, 'last': last, 'addr1': addr1, 'addr2': addr2, 'tel': '123-456-789'}
requests.post(URL, d)
The dict literal contains a lot of duplicated words and quotation marks. Using dict type looks nicer, but still verbose.
d = dict(first=first, last=last, addr1=addr1, addr2=addr2, tel='123-456-789')
With recent JavaScript, the same object can be written more easily.
d = {first, last, addr1, addr2, tel='123-456-789'}
How about adding similar syntax to Python? Like raw strings, we can add prefix letters such as '$' to the opening curly brace for the purpose.
d = ${first, last, addr1, addr2, tel='123-456-789'}
Keys should be valid identifier strings. Other keys raise SyntaxError.
I wrote a simple POC implementation here. It looks working.
https://github.com/atsuoishimoto/cpython/pull/2
(I prefer to use `j` for the prefix over `$`, but I may need to study the parser more to use an ASCII letter as token.)