parameters: (path, forceload=0)
return_statement: return object
docstring: Locate an object by name or dotted path, importing as necessary.
docstring_summary: Locate an object by name or dotted path, importing as necessary.
docstring_tokens: Locate an object by name or dotted path importing as necessary .
function: def locate(path, forceload=0):
      """Locate an object by name or dotted path, importing as necessary."""
      parts = [part for part in split(path, '.') if part]
      module, n = None, 0
      while n < len(parts):
          nextmodule = safeimport(join(parts[:n+1], '.'), forceload)
          if nextmodule: module, n = nextmodule, n + 1
          else: break
      if module:
          object = module
      else:
          object = __builtin__
      for part in parts[n:]:
          try:
              object = getattr(object, part)
          except AttributeError:
              return None
      return object
function_tokens: def locate ( path , forceload = 0 ) : parts = [ part for part in split ( path , '.' ) if part ] module , n = None , 0 while n < len ( parts ) : nextmodule = safeimport ( join ( parts [ : n + 1 ] , '.' ) , forceload ) if nextmodule : module , n = nextmodule , n + 1 else : break if module : object = module else : object = __builtin__ for part in parts [ n : ] : try : object = getattr ( object , part ) except AttributeError : return None return object