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,}
register(d)
The dict literal above contains a lot of duplicated words and quotation marks.
JavaScript has shorthand notation of property names.
d = {first, last, addr1, addr2}
In Python, {first, last, addr1, addr2}
yields set object. So, how about adding a new notation to Python as follows.
d = {:first, :last, :addr1, :addr2}
This is equivalent to
d = {'first': first,
'last': last,
'addr1': addr1,
'addr2': addr2,}
We can use same notation for function call. Following function call in compileall.py:
results = executor.map(partial(compile_file,
ddir=ddir, force=force,
rx=rx, quiet=quiet,
legacy=legacy,
optimize=optimize,
invalidation_mode=invalidation_mode,
stripdir=stripdir,
prependdir=prependdir,
limit_sl_dest=limit_sl_dest,
hardlink_dupes=hardlink_dupes),
files)
can be writtern like this.
results = executor.map(partial(compile_file,
:ddir, :force,
:rx, :quiet,
:legacy,
:optimize,
:invalidation_mode,
:stripdir,
:prependdir,
:limit_sl_dest,
:hardlink_dupes),
files)
I wrote a simple POC implementation.
https://github.com/atsuoishimoto/cpython/pull/4
Thoughts?