def to_utf8_optional_iterator(x):
 if isinstance(x, basestring):
  return to_utf8(x)
 try:
  l = list(x)
 except TypeError as e:
  assert ('is not iterable' in str(e))
  return x
 else:
  return [to_utf8_if_string(e) for e in l]

def to_utf8_optional_iterator ( x ) : if isinstance ( x , basestring ) : return to_utf8 ( x ) try : l = list ( x ) except TypeError as e : assert ( 'is not iterable' in str ( e ) ) return x else : return [ to_utf8_if_string ( e ) for e in l ]
raise typeerror if x is a str or if x is an iterable which contains a str .