Shorthand dict literal initialization

I ran some numbers:

Number of py files processed 69,464
Total bytes processed 1019.38 MB
Total DRY matches 2499
Total non-DRY matches 78255
DRY / non-DRY % 3.19%

A bit underwhelming, but still. :​) Also, I didn’t count dictionaries where all keys were DRY except say, just one, which I think would have been fairer. But I got tired of poking at it.

Nice!

Thank you for helping with the terminology. I changed the title of the post.


Purely by accident – while doing some of that text processing – I ran across this from Vim’s :help Dictionary:

To avoid having to put quotes around every key the #{} form can be used in legacy script. This does require the key to consist only of ASCII letters, digits, ‘-’ and ‘_’. Example: :let mydict = #{zero: 0, one_key: 1, two-key: 2}

[otherwise it would be: :let mydict = {"zero": 0, "one_key": 1, "two-key": 2}].

I think I’m becoming more partial to Atsuo’s way. It seems less invasive.