On Sat, Feb 5, 2022, 12:19 PM Mirmojtaba Gharibi <mojtaba.ghar...@gmail.com> wrote:
> > With my proposal, using := to init (similar to how in math parlance, the > := is used for defining something for the first time) > > Dic = {} # format fruit:count > For fruit in fruits: > Dic[fruit]:= 0 > Dic[fruit]+=1 > To my eye, this does not look like a conditional assignment. And how would an operator like this work with objects other than dicts? Besides, it's easier and clearer to write this as dic = defaultdict(int) for fruit in fruits: dic[fruit] += 1 --- Bruce
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/TTWOSADQXTL6FMRYBSZGCGQWWH2UWX6W/ Code of Conduct: http://python.org/psf/codeofconduct/