code: def maybedotted(name):
      
      if not name:
          raise LookupError(
              'Not able to resolve %s' % name)
      if not hasattr(name, '__name__'):
          try:
              mod = importlib.import_module(name)
          except ImportError:
              attr = None
              if '.' in name:
                  names = name.split('.')
                  attr = names.pop(-1)
                  try:
                      mod = maybedotted('.'.join(names))
                  except LookupError:
                      attr = None
                  else:
                      attr = getattr(mod, attr, None)
              if attr is not None:
                  return attr
              raise LookupError(
                  'Not able to resolve %s' % name)
          else:
              return mod
      return name
docs: Resolve dotted names:
  
      .. code-block:: python
  
          >>> maybedotted('irc3.config')
          <module 'irc3.config' from '...'>
          >>> maybedotted('irc3.utils.IrcString')
          <class 'irc3.utils.IrcString'>
  
      ..