2023-06-22

Inconsistency on module in IPython

IPython seems inconsistent here:

In [1]: import sys

In [2]: sys.version
Out[2]: '3.10.11 (main, May 16 2023, 00:28:57) [GCC 11.2.0]'

In [4]: type(sys)
Out[4]: module

In [5]: type(module)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[5], line 1
----> 1 type(module)

NameError: name 'module' is not defined

In [6]: type(type(sys))
Out[6]: type

How can something that is not defined be a type and have a type?

I found this after discovering that no class module exists, although, if I import some module of mine, it automatically inherits attributes

 '__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__spec__',

What are these attributes inherited from?



No comments:

Post a Comment