当前位置:网站首页>Should wildcard import be avoided- Should wildcard import be avoided?

Should wildcard import be avoided- Should wildcard import be avoided?

2022-07-06 15:08:00 fyin1314

problem :

I'm using PyQt and am running into this issue. I am using PyQt And encountered this problem .If my import statements are: If my import statement is :

from PyQt4.QtCore import *from PyQt4.QtGui import *

then pylint gives hundreds of "Unused import" warnings. then pylint Hundreds of “ Unused imports ” Warning .I'm hesitant to just turn them off, because there might be other unused imports that are actually useful to see. I'm hesitant to close them , Because there may be other unused imports that are actually useful .Another option would be to do this: Another option is to do so :

from PyQt4.QtCore import Qt, QPointF, QRectFfrom PyQt4.QtGui import QGraphicsItem, QGraphicsScene, ...

and I end up having 9 classes on the QtGui line. I ended up in QtGui On line 9 A course .There's a third option, which is: There is a third option , namely :

from PyQt4 import QtCore, QtGui

and then prefix all the classes with QtCore or QtGui whenever I use them. Then whenever I use them , use QtCore or QtGui Prefix all classes .

At this point I'm agnostic as to which one I end up doing in my project, although the last one seems the most painful from my perspective. At this point , I don't know which one I finally did in my project , Although from my point of view , The last one seems to be the most painful .What are the common practices here? What are the common practices here ?Are there technical reason to use one style over the other? Is there a technical reason to use one style instead of another ?


Solution :

Reference resources : https://stackoom.com/en/question/FAST
原网站

版权声明
本文为[fyin1314]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131325134672.html