New submission from Jordan Bettis <jord...@hafdconsulting.com>: Hi. I just spent a while fighting with imp.find_module because I was trying to pass the path as a string, rather than a string embedded in a list:
result = find_module('mod', '/path') rather than result = find_module('mod', ['/path']) The issue is compounded by an incredibly unhelpful error message: ImportError: No frozen submodule named /path.mod Now the documentation *does* say that path should be a list, if you read it carefully, so perhaps it was just my reading comprehension. But doing a google search I found a discussion from 2006 along the same lines: http://www.techlists.org/archives/programming/pythonlist/2006-01/msg01445.shtml So I thought it might be good to clarify that a string will not work. Perhaps the wording could be changed to something like this: Try to find the module *name* on the search path *path*. The *path* argument is a list of directory names. Each directory is searched for files with any of the suffixes returned by :func:`get_suffixes` above. Invalid names in the list are silently ignored (but all list items must be strings). If *path* is omitted or ``None``, the list of directory names given by ``sys.path`` is searched, but first it searches a few special places: it tries to find a built-in module with the given name (:const:`C_BUILTIN`), then a frozen module (:const:`PY_FROZEN`), and on some systems some other places are looked in as well (on Windows, it looks in the registry which may point to a specific file). I think what is confusing is the conditional about the type of 'path', The possibilities are 'list' or 'not present' (or None) but when I read it I think I saw the 'not present' option as being implicit, and the conditional implying that it could be a string or a list of strings. >From the discussion above it seems like the other person had the same trouble, so removing the conditional should be enough to make it clear that path *must* be a list if it exists. ---------- assignee: georg.brandl components: Documentation messages: 90333 nosy: georg.brandl, jordanb severity: normal status: open title: imp.find_module() -- be explicity that 'path' must be a list versions: Python 2.4, Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1, Python 3.2 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6448> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com