Nov-21-2018, 12:19 AM
here is an idea that i sure wanted to code in tonight's project.
while doing some scanning i put some info into a dictionary. but there was one point where i needed to put a few key:value pairs in at the same time, so i ended up coding something like:
the opinion i am soliciting is whether this kind syntactic sugar should be a [art of the language, if it were the developers asking for a public vote. unfortunately, i won't be able to offer much justification. it doesn't shorten much, but it does remove () from around {} which makes it easier to read, IMHO.
while doing some scanning i put some info into a dictionary. but there was one point where i needed to put a few key:value pairs in at the same time, so i ended up coding something like:
info.update({'freq':freq,'band':band,'mode':mode,'power':power,'antenna':antnum})but, because the first coding pass had used a list, i wanted to code it more like:
info += {'freq':freq,'band':band,'mode':mode,'power':power,'antenna':antnum}the meaning is the same, but because i had been coding some += operations already, my brain was ready to just keep doing so. if this were being done with a set, then |= might make more sense. and due to the similarity between a set and a dictionary, it might make more sense to some to use |= instead of += to join one dictionary to another.
the opinion i am soliciting is whether this kind syntactic sugar should be a [art of the language, if it were the developers asking for a public vote. unfortunately, i won't be able to offer much justification. it doesn't shorten much, but it does remove () from around {} which makes it easier to read, IMHO.