How the following code can be simplified?
photo = soup.find('div', {'class': 'flagPageTitle'}).nextSibling.find('img')
if photo:
photo = 'http://www.example.com' + photo['src']
else:
photo = None
How the following code can be simplified?
|
|||
|
So you can just write:
| ||||
|
You could do
Though ternary operator can be questioned for simplicity. Often it's harder to read code with big ternary operators. Use it with care. | |||
|