You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I kinda like it, however it doesn't seem to be that useful, as well as map being unpythonic (list comprehensions are better! :))
sel.xpath("//@data-p13n-asin-metadata").map([json.loads, lambda d: d.get('asin'))
# vs
[json.loads(v).get('asin') for v in sel.xpath("//@data-p13n-asin-metadata").extract()]
As the comparison shows map doesn't really add much. Sure it might look a bit more tidy but list comprehension are more straigh-forward and most importantly more explicit.
Also you can use dict, set and generator comprehensions!
So I feel on the edge - would be nice but seems awfully unnecessary and inferrior to comprehensions.
Sometimes I'd like to apply some function after extracting something, and I do something like this:
what do you think about adding support for map on selector result level? So that I could do
or even allow to pass list of functions
?
The text was updated successfully, but these errors were encountered: