<div style=""><div style=""><div>You are absolutely right on the `import *` relevant issue .</div><div>I also agree with the "Importing Objects" part of book Rapid GUI Programming with Python and Qt: The Definitive Guide to PyQt </div><div>https://books.google.com/books?id=9oRa4WJLlGkC&lpg=PP1&pg=PT33#v=onepage&q&f=false</div><div><br></div><div>I choose to use the `import *` style in PyQt for the sake of brevity, and use the plain import syntax for other modules .</div><div><br></div></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px;"><br></div><div style="color: rgb(0, 0, 0); font-family: arial; font-size: 14px;"><br></div></div><!-- jy5ContentSuffix --><div>在2018年06月28 19时27分, "Kyle Altendorf"<sda@fstab.net>写道:</div><blockquote id="isReplyContent" style="padding-left:1ex; margin: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br>On 2018-06-28 01:25, Zhao Lee wrote:<br>> but now I could replace all of them with only " from PyQt5.Qt import * <br>> "<br><br>> any drawback along with the single line import ?<br><br>The doc you linked explained the memory cost of importing anything via <br>the PyQt5.Qt module.  There are additional reasons that from imports are <br>somewhat risky and * imports are generally fairly questionable.<br><br>When you `from x import y` you are making a new name (`y`) referencing <br>the object referenced by `x.y` at that point in time.  Generally, module <br>globals (such as `y` in this example) should not be reassigned but it <br>can and does happen.  Then when you use `y` you will still get the old <br>object, not the new.<br><br>https://repl.it/@altendky/why-not-to-from-import<br><br>`from x import *` has the same issue, but additionally people reading <br>the code don't know where names came from.  With a single `import *` <br>it's annoying, with two...  we end up having to add diagnostics to the <br>code and run it ourselves to figure out where the otherwise unknown <br>variables came from.  Dumping things into the module scope with this <br>hazards some confusing behavior with some packages like numpy that have <br>lots of things with fairly 'normal' names in them.  You end up with <br>collisions and some names being unexpectedly overwritten possibly <br>depending on the order of imports.<br><br>Admittedly, Qt suffers from mostly the opposite namespacing issue in <br>that you end up triple namespaced because each layer of <br>PyQt5.QtWidgets.QApplication has the indicative Q in it.  Still, these <br>problems are generally relevant to `from` and `*` imports.<br><br>Cheers,<br>-kyle<br></blockquote><br><br><span title="neteasefooter"><p> </p></span>