The doc string for find_module doesn't make it clear that you can do: stats_path = imp.find_module('scipy/stats') It makes it sound like you would have to do: scipy_path = imp.find_module('scipy')[1] stats_path = imp.find_module('scipy', stats_path)[1] However, the shorter snippet seems to work just fine.
Are you sure it works the same? I would expect that (1) The longer form first finds a module (or package) named scipy, then finds the (sub-)module stats within it. The shortcut form might not provide enough of the scipy context. (Whether this actually matters probably depends on what stats does, how much it depends on the rest of scipy, and what you need it for.) (2) The longer form would work using python abstractions, while the short form would depend on how files happened to be stored on your machine. Your storage format is fairly common, but not guaranteed. For example, would the short form work on windows, where directory slashes (sometimes) need to go the other direction? Would it work if scipy were in a zipfile egg?