dict.get(key, default) evaluates default even if key exists
Hi. # Running this script D = {'a':1} def get_default(): print('Nobody expects this') return 0 print(D.get('a', get_default())) # ...generates this output: Nobody expects this 1 ### Since I'm brand new to this community, I thought I'd ask here first... Is this worthy of a bug rep
Re: dict.get(key, default) evaluates default even if key exists
Storchaka wrote: 15.12.20 19:07, Mark Polesky via Python-list пише: > # Running this script > > D = {'a':1} > def get_default(): > print('Nobody expects this') > return 0 > print(D.get('a', get_default())) > >