'Static method to construct a Key out of a "path" (kind, id or name, ...).
This is useful when an application wants to use just the id or name portion
of a key in e.g. a URL, where the rest of the URL provides enough context to
fill in the rest, i.e. the app id (always implicit), the entity kind, and
possibly an ancestor key. Since ids and names are usually small, they\'re
more attractive for use in end-user-visible URLs than the full string
representation of a key.
Args:
kind: the entity kind (a str or unicode instance)
id_or_name: the id (an int or long) or name (a str or unicode instance)
parent: optional parent Key; default None.
namespace: optional namespace to use otherwise namespace_manager\'s
default namespace is used.
Returns:
A new Key instance whose .kind() and .id() or .name() methods return
the *last* kind and id or name positional arguments passed.
Raises:
BadArgumentError for invalid arguments.
BadKeyError if the parent key is incomplete.'

@staticmethod
def from_path(*args, **kwds):

    parent = kwds.pop('parent', None)
    app_id = ResolveAppId(kwds.pop('_app', None))
    namespace = kwds.pop('namespace', None)
    if kwds:
        raise datastore_errors.BadArgumentError(('Excess    keyword    arguments    ' + repr(kwds)))
    if ((not args) or (len(args) % 2)):
        raise datastore_errors.BadArgumentError(('A    non-zero    even    number    of    positional    arguments    is    required    (kind,    id    or    name,    kind,    id    or    name,    ...);    received    %s' % repr(args)))
    if (parent is not None):
        if (not isinstance(parent, Key)):
            raise datastore_errors.BadArgumentError(('Expected    None    or    a    Key    as    parent;    received    %r    (a    %s).' % (parent, typename(parent))))
        if (namespace is None):
            namespace = parent.namespace()
        if (not parent.has_id_or_name()):
            raise datastore_errors.BadKeyError('The    parent    Key    is    incomplete.')
        if ((app_id != parent.app()) or (namespace != parent.namespace())):
            raise datastore_errors.BadArgumentError(('The    app/namespace    arguments    (%s/%s)    should    match    parent.app/namespace()    (%s/%s)' % (app_id, namespace, parent.app(), parent.namespace())))
    namespace = ResolveNamespace(namespace)
    key = Key()
    ref = key.__reference
    if (parent is not None):
        ref.CopyFrom(parent.__reference)
    else:
        ref.set_app(app_id)
        SetNamespace(ref, namespace)
    path = ref.mutable_path()
    for i in xrange(0, len(args), 2):
        (kind, id_or_name) = args[i:(i + 2)]
        if isinstance(kind, basestring):
            kind = kind.encode('utf-8')
        else:
            raise datastore_errors.BadArgumentError(('Expected    a    string    kind    as    argument    %d;    received    %r    (a    %s).' % ((i + 1), kind, typename(kind))))
        elem = path.add_element()
        elem.set_type(kind)
        if isinstance(id_or_name, (int, long)):
            elem.set_id(id_or_name)
        elif isinstance(id_or_name, basestring):
            ValidateString(id_or_name, 'name')
            elem.set_name(id_or_name.encode('utf-8'))
        else:
            raise datastore_errors.BadArgumentError(('Expected    an    integer    id    or    string    name    as    argument    %d;    received    %r    (a    %s).' % ((i + 2), id_or_name, typename(id_or_name))))
    assert ref.IsInitialized()
    return key
