In Python I have a list of strings, some of which may be the empty string. What\'s the best way to get the first non-empty string?
Here's a short way:
filter(None, list_of_strings)[0]
EDIT:
Here's a slightly longer way that is better:
from itertools import ifilter ifilter(None, list_of_strings).next()