Update page 'Day 10 homework - Sloetjes '
@@ -79,6 +79,31 @@ if __name__ == '__main__':
|
||||
|
||||
By using a set called `module_files` to keep track of the filenames of the modules that we have counted so far. Before counting a module, we check if its filename has been counted already. If it has, we skip the module and move on to the next one. This ensures that similar module names are counted only once.
|
||||
|
||||
###### Output:
|
||||
|
||||
```
|
||||
Total modules: 1011
|
||||
Bytecode modules: 0 (0.00%)
|
||||
DSO modules: 51 (5.04%)
|
||||
Python modules: 960 (94.96%)
|
||||
|
||||
Module directory histogram:
|
||||
/Users/sloetjeswong/opt/anaconda3/lib/python3.9: ***************************************************************************************************************
|
||||
/Users/sloetjeswong/opt/anaconda3/lib/python3.9/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle: ************************************************
|
||||
/Users/sloetjeswong/opt/anaconda3/lib/python3.9/site-packages/IPython/core: *******************************************
|
||||
/Users/sloetjeswong/opt/anaconda3/lib/python3.9/lib-dynload: **************************************
|
||||
/Users/sloetjeswong/opt/anaconda3/lib/python3.9/site-packages/IPython/utils: ********************************
|
||||
/Users/sloetjeswong/opt/anaconda3/lib/python3.9/asyncio: **************************
|
||||
/Users/sloetjeswong/opt/anaconda3/lib/python3.9/site-packages/jedi/inference: **********************
|
||||
/Users/sloetjeswong/opt/anaconda3/lib/python3.9/site-packages/setuptools/_distutils: *******************
|
||||
/Users/sloetjeswong/opt/anaconda3/lib/python3.9/site-packages/setuptools: ******************
|
||||
/Users/sloetjeswong/opt/anaconda3/lib/python3.9/site-packages/jupyter_client: *****************
|
||||
/Users/sloetjeswong/opt/anaconda3/lib/python3.9/email: *****************
|
||||
/Users/sloetjeswong/opt/anaconda3/lib/python3.9/site-packages/ipykernel: ****************
|
||||
/Users/sloetjeswong/opt/anaconda3/lib/python3.9/site-packages/prompt_toolkit: ****************
|
||||
/Users/sloetjeswong/opt/anaconda3/lib/python3.9/site-packages/IPython/core/magics: ***************
|
||||
```
|
||||
|
||||
**4. Inspect the `loader` attribute of each entry in the `sys.modules` dict. Can you find an attribute of `loader` which reliably tells you if the loader is source, builtin, or extension?**
|
||||
|
||||
##### Answer: Yes, the attribute name of the loader object can be used to determine if the loader is source, builtin, or extension.
|
||||
|
||||
Reference in New Issue
Block a user