Difference between a ‘for’ loop and map

A very interesting question which has an interesting answer.

The map function returns a Map object which is iterable. map is performing its calculation lazily so the function wouldn’t get called unless you iterate that object.

So if you do:

x = map(D.attach_item, items)
for i in x:
    continue

The expected result will show up.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)