Quote:
Originally Posted by DaWei
I think you might agree that some of the forms of some of the abstractions (generators, etc.) approach obscurity without resulting in leaner code or clearer thought.
|
That's true. On the one hand, list comprehensions can result in clearer code:
# Without
urls = []
for tag in soup.fetch_all("a"):
urls.append(tag['href'])
# With
urls = [tag['href'] for tag in soup.fetch_all("a")]
On the other hand...
def q(s):
if len(s)<=1:return s
return q([l for l in s[1:] if l<s[0]])+[s[0]]+q([g for g in s[1:] if g>=s[0]])