def namedAny(name):
if not name:<EOL><INDENT>raise InvalidName('<STR_LIT>')<EOL><DEDENT>names = name.split('<STR_LIT:.>')<EOL>if '<STR_LIT>' in names:<EOL><INDENT>raise InvalidName(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>" % (name,))<EOL><DEDENT>topLevelPackage = None<EOL>moduleNames = names[:]<EOL>while not topLevelPackage:<EOL><INDENT>if moduleNames:<EOL><INDENT>trialname = '<STR_LIT:.>'.join(moduleNames)<EOL>try:<EOL><INDENT>topLevelPackage = _importAndCheckStack(trialname)<EOL><DEDENT>except _NoModuleFound:<EOL><INDENT>moduleNames.pop()<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if len(names) == <NUM_LIT:1>:<EOL><INDENT>raise ModuleNotFound("<STR_LIT>" % (name,))<EOL><DEDENT>else:<EOL><INDENT>raise ObjectNotFound('<STR_LIT>' % (name,))<EOL><DEDENT><DEDENT><DEDENT>obj = topLevelPackage<EOL>for n in names[<NUM_LIT:1>:]:<EOL><INDENT>obj = getattr(obj, n)<EOL><DEDENT>return obj<EOL>
Retrieve a Python object by its fully qualified name from the global Python
module namespace.  The first part of the name, that describes a module,
will be discovered and imported.  Each subsequent part of the name is
treated as the name of an attribute of the object specified by all of the
name which came before it.  For example, the fully-qualified name of this
object is 'twisted.python.reflect.namedAny'.

@type name: L{str}
@param name: The name of the object to return.

@raise InvalidName: If the name is an empty string, starts or ends with
    a '.', or is otherwise syntactically incorrect.

@raise ModuleNotFound: If the name is syntactically correct but the
    module it specifies cannot be imported because it does not appear to
    exist.

@raise ObjectNotFound: If the name is syntactically correct, includes at
    least one '.', but the module it specifies cannot be imported because
    it does not appear to exist.

@raise AttributeError: If an attribute of an object along the way cannot be
    accessed, or a module along the way is not found.

@return: the Python object identified by 'name'.