parameters: (instance, args)
docstring: Convert the sequence `args` to the same type as `instance`.
docstring_summary: Convert the sequence `args` to the same type as `instance`.
docstring_tokens: Convert the sequence args to the same type as instance .
function: def _sequence_like(instance, args):
      """
      Convert the sequence `args` to the same type as `instance`.
      """
      if isinstance(instance, dict):
          # Pack dictionaries in a deterministic order by sorting the keys.
          # Notice this means that we ignore the original order of `OrderedDict`
          # instances. This is intentional, to avoid potential bugs caused by mixing
          # ordered and plain dicts (e.g., flattening a dict but using a
          # corresponding `OrderedDict` to pack it back).
          result = dict(zip(_sorted(instance), args))
          return type(instance)((key, result[key])
                                for key in six.iterkeys(instance))
      elif (isinstance(instance, tuple) and hasattr(instance, "_fields") and
            isinstance(instance._fields, collections.Sequence) and
            all(isinstance(f, six.string_types) for f in instance._fields)):
          # This is a namedtuple
          return type(instance)(*args)
      else:
          # Not a namedtuple
          return type(instance)(args)
function_tokens: def _sequence_like ( instance , args ) : if isinstance ( instance , dict ) : # Pack dictionaries in a deterministic order by sorting the keys. # Notice this means that we ignore the original order of `OrderedDict` # instances. This is intentional, to avoid potential bugs caused by mixing # ordered and plain dicts (e.g., flattening a dict but using a # corresponding `OrderedDict` to pack it back). result = dict ( zip ( _sorted ( instance ) , args ) ) return type ( instance ) ( ( key , result [ key ] ) for key in six . iterkeys ( instance ) ) elif ( isinstance ( instance , tuple ) and hasattr ( instance , "_fields" ) and isinstance ( instance . _fields , collections . Sequence ) and all ( isinstance ( f , six . string_types ) for f in instance . _fields ) ) : # This is a namedtuple return type ( instance ) ( * args ) else : # Not a namedtuple return type ( instance ) ( args )