Nifty, little one-liner I learned today. Instead of doing this:
def func(foo):
if foo == 0:
return "bar"
else:
return "baz"
You can simply do this:
def func(foo):
return "bar" if foo == 0 else "baz"
Pretty cool for those who didn't know. ;-)
- Karan Goel
View comments