[Python-ideas] Re: Unit variables upon their first appearance

2022-02-05 Thread Bruce Leban
On Sat, Feb 5, 2022, 12:19 PM Mirmojtaba Gharibi 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

[Python-ideas] Re: Unit variables upon their first appearance

2022-02-05 Thread Rob Cliffe via Python-ideas
Hi Mirmojtaba, thanks for your suggestion. I doubt this idea will fly with this syntax because it could easily be confused with the walrus operator. x := 0 is *almost* legal syntax currently.  In fact (x := 0) is legal, and it is quite possible that at some time in the future    

[Python-ideas] Re: Unit variables upon their first appearance

2022-02-05 Thread David Mertz, Ph.D.
This is `collections.Counter`. On Sat, Feb 5, 2022, 3:19 PM Mirmojtaba Gharibi wrote: > Hello there, > > I have an idea for initializing a variable the first time it’s created; it > can especially be helpful with containers, and dicts specifically. Let me > demonstrate with some examples: > >