Hi,
I am not sure if this something that should be done, or if this bad practice. But I wanted something like this to work.
import toolz
some_dict = {"hello": "world", "foo": "bar", "number": 0}
def first_func(hello, foo, **kwargs):
hello = "John"
foo = "baz"
kwargs['newvalue'] = True
return kwargs
def second_func(number, **kwargs):
number = number + 1
kwargs['number'] = number
kwargs['anothervalue'] = False
return kwargs
running something like this works:
first_func(**some_dict)
>>>
{'number': 0, 'newvalue': True}
second_func(**some_dict)
>>>
{'number': 1, 'anothervalue': False}
But this won't work, which I understand why.
new_dict = toolz.pipe(**some_dict, first_func, second_func)
The idea is that I want some_dict to remain untouched, but new_dict to capture relevant information along the way.
Is this bad practice? Or not a relevant usecase? or is there a better way to do this?
Hi,
I am not sure if this something that should be done, or if this bad practice. But I wanted something like this to work.
running something like this works:
But this won't work, which I understand why.
The idea is that I want some_dict to remain untouched, but new_dict to capture relevant information along the way.
Is this bad practice? Or not a relevant usecase? or is there a better way to do this?