[Python-Dev] bug or feature in imp.load_module()? (original) (raw)

Guido van Rossum guido@python.org
Wed, 17 Oct 2001 13:32:00 -0400


module = imp.loadmodule(path, file, filename, smt)

After returning from imp.loadmodule(), the file paramter passed in may be at the beginning or end depending on whether it was byte compiled. If the file was already compiled, the file returned will stay at the beginning. If the file was byte compiled in loadmodule(), the file will be at the end.

This certainly doesn't surprise me -- in one case it read the source and in the other case it didn't read the source.

If you pass a file to a function, I don't think that there is any guarantee to the file position when it returns, so I don't think this should be documented. I can't think of why you'd expect it to be at any specific position.

--Guido van Rossum (home page: http://www.python.org/~guido/)