default argument value is mutable
Marko Rauhamaa
marko at pacujo.net
Fri Oct 7 14:02:26 EDT 2016
More information about the Python-list mailing list
Fri Oct 7 14:02:26 EDT 2016
- Previous message (by thread): default argument value is mutable
- Next message (by thread): default argument value is mutable
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"D'Arcy J.M. Cain" <darcy at Vex.Net>: > On Fri, 07 Oct 2016 16:09:19 +0200 > jmp <jeanmichel at sequans.com> wrote: >> What about >> >> def test(): >> if not hasattr(test, '_store'): test._store={'x':0} >> test._store['x'] += 1 > > Why is everyone working so hard to avoid creating a class? Hear, hear! Marko
- Previous message (by thread): default argument value is mutable
- Next message (by thread): default argument value is mutable
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list