code: def isdefined(obj, force_import=False, namespace=None):
      
      if namespace is None:
          namespace = locals()
      attr_list = obj.split('.')
      base = attr_list.pop(0)
      if len(base) == 0:
          return False
      if base not in builtins.__dict__ and base not in namespace:
          if force_import:
              try:
                  module = __import__(base, globals(), namespace)
                  if base not in globals():
                      globals()[base] = module
                  namespace[base] = module
              except Exception:
                  return False
          else:
              return False
      for attr in attr_list:
          try:
              attr_not_found = not hasattr(eval(base, namespace), attr)
          except (SyntaxError, AttributeError):
              return False
          if attr_not_found:
              if force_import:
                  try:
                      __import__(base+'.'+attr, globals(), namespace)
                  except (ImportError, SyntaxError):
                      return False
              else:
                  return False
          base += '.'+attr
      return True
docs: Return True if object is defined in namespace
      If namespace is None --> namespace = locals()