Closed ChengkaiYang2022 closed 5 years ago
# example where a python function modifies the original dictionary
$ python
Python 3.7.3 (default, Mar 27 2019, 09:23:15)
[Clang 10.0.1 (clang-1001.0.46.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> d = {'key':'value'}
>>> def f(d):
... del d['key']
...
>>> f(d)
>>> d
{}
>>>
vs
# non-modifying version
$ python
Python 3.7.3 (default, Mar 27 2019, 09:23:15)
[Clang 10.0.1 (clang-1001.0.46.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> d = {'key':'value2'}
>>> def f(d):
... d2 = dict(d)
... del d2['key']
... print(d2)
...
>>> d
{'key': 'value2'}
>>> f(d)
{}
>>> d
{'key': 'value2'}
>>>
modifies
Thanks for reply!I understand know:)
hi,In crawler/crawling/pipelines.py in the "LoggingBeforePipeline" class,there is a variable called "item_copy" in function process_item,it just simple turn item into a dict,and delete some keys like "body","links" and after that it does nothing except for logging. So what is the purpose for the "item_copy"? And I also have another question here,if the item is not RawResponseItem,maybe like a user defined Item,it will return None,and the following Pipeline will not recive the item,and those will do nothing. I'm so confused about this function here.?