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

zljubisic at gmail.com zljubisic at gmail.com
Sun Jun 14 13:55:02 EDT 2020


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 dict[k] value.

Now when I have dict prepared with proper key/values pairs, I am proceeding to execution of the jinjasql query.

What I have to ensure is that I will get dic[str, List] (I could go further and ensure that list contains only object of certain class, by the way, how to do that?).

Than I must ensure that I am working on local copy of parameters.

Anyway, copy that Dieter Maurer suggested works as it should.
Thanks.


More information about the Python-list mailing list