Issue
Is there a way to make this code prettier?
strong = li.find_all("strong") if strong: yield li.find_all("strong")
I mean something like this:
strong = li.find_all("strong") yield li.find_all("strong") if strong
Solution
You'd use:
strong = li.find_all("strong")
if strong:
yield strong
instead of calling find_all()
again (which, in BeautifulSoup, gives the same result but does the work again).
There is no 'conditional yield'. You could play tricks with yield from
but I'd recommend against that.
Answered By - Martijn Pieters
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.