Re: How to keep Dict[str, List] default method parameter as local to the method?

2020-06-14 Thread zljubisic
Thanks for the video. Now it is clear to me what has happened and why copy solves the problem. -- https://mail.python.org/mailman/listinfo/python-list

Re: How to keep Dict[str, List] default method parameter as local to the method?

2020-06-14 Thread zljubisic
params = {} if params is None else params.copy() has solved the problem. I have provided just a toy example here. Execute method actually takes dict[str, List]. List contains objects. Each object has two properties, so I have a logic that analyzes these properties and returns None or List as a

Re: How to keep Dict[str, List] default method parameter as local to the method?

2020-06-14 Thread Peter J. Holzer
On 2020-06-14 19:44:32 +0200, Peter J. Holzer wrote: > [1] There is a very good talk by Raymond Hettinger on how variables and > objects in Python work. Unfortunately I can't find it at the moment. Sorry, that talk was by Ned Batchelder (that's why I couldn't find it): https://www.youtube.com

Re: How to keep Dict[str, List] default method parameter as local to the method?

2020-06-14 Thread Peter J. Holzer
On 2020-06-14 08:20:46 -0700, zljubi...@gmail.com wrote: > consider this example: > > from typing import Dict, List > > > class chk_params: > def execute(self, params: Dict[str, List] = None): > if params is None: > params = {} > > for k, v in params.items(): >

Re: How to keep Dict[str, List] default method parameter as local to the method?

2020-06-14 Thread Peter Otten
zljubi...@gmail.com wrote: > Hi, > > consider this example: > > from typing import Dict, List > > > class chk_params: > def execute(self, params: Dict[str, List] = None): > if params is None: > params = {} > > for k, v in params.items(): > params[k]

Re: How to keep Dict[str, List] default method parameter as local to the method?

2020-06-14 Thread Dieter Maurer
zljubi...@gmail.com wrote at 2020-6-14 08:20 -0700: >Hi, > >consider this example: > >from typing import Dict, List > > >class chk_params: >def execute(self, params: Dict[str, List] = None): >if params is None: >params = {} > >for k, v in params.items(): >

Re: How to keep Dict[str, List] default method parameter as local to the method?

2020-06-14 Thread Kushal Kumaran
zljubi...@gmail.com writes: > Hi, > > consider this example: > > from typing import Dict, List > > > class chk_params: > def execute(self, params: Dict[str, List] = None): > if params is None: > params = {} > > for k, v in params.items(): > params[k] = [

How to keep Dict[str, List] default method parameter as local to the method?

2020-06-14 Thread zljubisic
Hi, consider this example: from typing import Dict, List class chk_params: def execute(self, params: Dict[str, List] = None): if params is None: params = {} for k, v in params.items(): params[k] = [val + 10 for val in v] return params.values