From the title, yes there is a difference. Now applied to my scenario: let's consider a class Dummy
:
class Dummy:
def __init__(self):
self.attached = []
def attach_item(self, item):
self.attached.append(item)
If I use this:
D = Dummy()
items = [1, 2, 3, 4]
for item in items:
D.attach_item(item)
I indeed get D.attached = [1, 2, 3, 4]
. But if I map the function attach_item
to the items
, D.attached
remains empty.
map(D.attach_item, items)
What is it doing?