@contextmanager
def file_or_filename(input):
 if isinstance(input, string_types):
  (yield smart_open(input))
 else:
  input.seek(0)
  (yield input)

@ contextmanager def file_or_filename ( input ) : if isinstance ( input , string_types ) : ( yield smart_open ( input ) ) else : input . seek ( 0 ) ( yield input )
return a file-like object ready to be read from the beginning .