When is a module imported from the standard library?
Ignacio Vazquez-Abrams
ignacio at openservices.net
Wed Aug 22 18:50:01 EDT 2001
On Wed, 22 Aug 2001, Skip Montanaro wrote:
>
> [snip]
>
> All modules in those directories should have a valid __file__ attribute. In
> addition, modules that are statically linked into the interpreter will not
> have a __file__ attribute, so you can't really tell if they are part of the
> core or a third-party extension that was statically linked into the
> interpreter.
Not true, strictly speaking:
>>> import imp
>>> imp.find_module('sys')[2][2]==imp.C_BUILTIN
1
>>> imp.find_module('sys')[2][2]==imp.C_EXTENSION
0
>>> imp.find_module('os')[2][2]==imp.C_EXTENSION
0
>>> imp.find_module('os')[2][2]==imp.PY_SOURCE
1
>>>
--
Ignacio Vazquez-Abrams <ignacio at openservices.net>
More information about the Python-list
mailing list