Re: Empty list as a default param - the problem, and my suggested solution

2021-08-14 Thread Martin Di Paola
I don't know if it is useful but it is an interesting metaprogramming/reflection challenge. You used `inspect` but you didn't take its full potential. Try to see if you can simplify your code and see if you can come with a decorator that does not require special parameters. from new import N

Empty list as a default param - the problem, and my suggested solution

2021-08-13 Thread guruyaya
I am fairly sure all of us know about this python quirk: >>> def no_new_func(a=[]): ...a.append('new') ...return a >>> no_new_func() ['new'] >>> no_new_func() ['new', 'new'] >>> For some time I was bothered about that there's no elegant way to use empty list or dict as a default