Python Forum

Full Version: Python 3.7.7 Bug?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is anyone else experiencing an import bug in the latest 3.7 version

Example:

File a
 import b
 
 print(b.something.a)
(AttributeError: type object 'something' has no attribute 'a')

File b
class something:
      a = 0
I am using a virtual environment currently experimenting with other interpreters to make sure its just 3.7 and not me
Try print(b) to see which file was actually read.
Works fine for me Python 3.7.
C:\code
λ ptpython
>>> import b

>>> b
<module 'b' from 'C:\\code\\b.py'>
>>> b.something
<class 'b.something'>
>>> b.something.a
0

>>> b.something.a = 99
>>> print(b.something.a)
99
A better Python REPL like ptpython or IPython can help when inspect any module or package.
I like ptpython as it show all attributes automatic,IPython press Ctrl-Backspace,.
[Image: LKnPan.png]