salastro / math-expert

Incomplete easy-to-use math solver and PDF generator.
MIT License
22 stars 5 forks source link

Better define methods in `main.py` #19

Open salastro opened 2 years ago

salastro commented 2 years ago

Currently, exec is used, which is very unpythonic and inefficient. There should be a way to get all the functions in the func.py and link them accordingly.

    operations = ["inte", "diff", "lim", "fact", "sol",
                  "simp", "eval", "plot", "generate_pdf", "generate_latex"]

    for func in operations:
        exec(f"""
            \n@pyqtSlot()
            \ndef on_{func}_bt_clicked(self):
            \n    self.mathdoc.{func}(self.expression.toPlainText().\
                replace(" ", ""))
        """)
salastro commented 2 years ago

https://stackoverflow.com/a/49631500