def up_to_first_space(s):
    """Return the substring of s up to the first space, or all of s if it does
    not contain a space."""
    i = s.find(' ')
    if i == -1:
        i = len(s)
    return s[:i]