def __repr__(self):
    """String representation, used by str() and repr().

    We produce a short string that conveys all relevant information,
    suppressing app and namespace when they are equal to the default.
    """
    # TODO: Instead of "Key('Foo', 1)" perhaps return "Key(Foo, 1)" ?
    args = []
    for item in self.flat():
      if not item:
        args.append('None')
      elif isinstance(item, basestring):
        if not isinstance(item, str):
          raise TypeError('Key item is not an 8-bit string %r' % item)
        args.append(repr(item))
      else:
        args.append(str(item))
    if self.app() != _DefaultAppId():
      args.append('app=%r' % self.app())
    if self.namespace() != _DefaultNamespace():
      args.append('namespace=%r' % self.namespace())
    return 'Key(%s)' % ', '.join(args)
dataset/ETHPy150Open GoogleCloudPlatform/datastore-ndb-python/ndb/key.py/Key.__repr__/original