Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python 3.7.7 Bug?
#1
Exclamation 
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
Reply
#2
Try print(b) to see which file was actually read.
Reply
#3
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]
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020