code: def get_modpath_from_modname(modname, prefer_pkg=False, prefer_main=False):
      
      from os.path import dirname, basename, join, exists
      initname = '__init__.py'
      mainname = '__main__.py'
      if modname in sys.modules:
          modpath = sys.modules[modname].__file__.replace('.pyc', '.py')
      else:
          import pkgutil
          loader = pkgutil.find_loader(modname)
          modpath = loader.filename.replace('.pyc', '.py')
          if '.' not in basename(modpath):
              modpath = join(modpath, initname)
      if prefer_pkg:
          if modpath.endswith(initname) or modpath.endswith(mainname):
              modpath = dirname(modpath)
      if prefer_main:
          if modpath.endswith(initname):
              main_modpath = modpath[:-len(initname)] + mainname
              if exists(main_modpath):
                  modpath = main_modpath
      return modpath
docs: Same as get_modpath but doesnt import directly
  
      SeeAlso:
          get_modpath