sys.modules

Chris Warrick kwpolska at gmail.com
Thu Feb 21 14:02:13 EST 2019


On Thu, 21 Feb 2019 at 18:57, ast <none at gmail.com> wrote:
>
> Hello
>
> Is it normal to have 151 entries in dictionary sys.modules
> just after starting IDLE or something goes wrong ?
>
>  >>> import sys
>  >>> len(sys.modules)
> 151
>
> Most of common modules seems to be already there,
> os, itertools, random ....
>
> I thought that sys.modules was containing loaded modules
> with import command only.

sys.modules contains all modules that have been imported in the
current session. Some of those imports happen in the background,
without your knowledge — for example, because these modules are
required by the interpreter itself, or are part of IDLE. The number
you see depends on the environment (I got 530 in ipython3, 34 in
python3, 45 in python2) and is not in any way important.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16


More information about the Python-list mailing list