title: Why should I import QtGui and QtCore in PyQt when it isn't necessary?
body: <p>I copied a PyQt example from the Web into a file and opened it up in PyCharm. Below is the code:</p>
  
  <pre><code>from PyQt5.QtGui import *
  from PyQt5.QtCore import *
  from PyQt5.QtWidgets import *
  from math import *
  
  
  class Calculator(QMainWindow):
      def __init__(self, parent=None):
          super().__init__(parent)
  
          self.browser = QTextBrowser()
          self.expression = QLineEdit()
          self.expression.setPlaceholderText("Type an expression and press Enter.")
          self.expression.selectAll()
  
          layout = QVBoxLayout()
          layout.addWidget(self.browser)
          layout.addWidget(self.expression)
          self.someWidget = QWidget()
          self.someWidget.setLayout(layout)
          self.setCentralWidget(self.someWidget)
          self.expression.setFocus()
  
          self.expression.returnPressed.connect(self.updateUi)
          self.setWindowTitle("Calculator")
  
      def updateUi(self):
          try:
              text = self.expression.text()
              self.browser.append("%s = %s", (text, eval(text)))
          except:
              self.browser.append("&lt;font color=red&gt;Invalid Expression&lt;/font&gt;")
  
  
  def main():
      import sys
      app = QApplication(sys.argv)
      window = Calculator()
      window.show()
      sys.exit(app.exec_())
  
  
  main()
  </code></pre>
  
  <p>The problem is that the code run well even without adding the following import statements:</p>
  
  <pre><code>from PyQt5.QtGui import *
  from PyQt5.QtCore import *
  from math import *
  </code></pre>
  
  <p>I have seen this example being used in many videos and books. If the code works good without the above statements, then why did the author of the example write the statements.</p>