Reputation: 1771
I want to make a library of files, where each file does basically the same - solving math problems - but each implementation is slightly different. The way I want to set this up is as follows:
main.py (has a list of all problems, user can enter parameters)
solves\
prob001.py Problem, with definition of inputs, perhaps several different
solve() methods(solve_1(), solve_2() ...)
prob002.py 2nd Problem, structurally the same.
....
As I progress, more problemXX.py
's will be added.
What code would I need to call solve_1
on prob002.py
, and how do I make this as flexible/scalable as possible. Simply typing out import prob001
then prob001.solve(x, y)
is not preferred, I want to generate menu's with options dynamically.
Upvotes: 0
Views: 48
Reputation: 455
Files: https://gist.github.com/thenarfer/330a4f978eab7c40e84e1dbaee062ebd
Check out the files for this script. Make sure to create the directory tree as follows:
math_solver_main.py
solves\
prob001.py
prob002.py
...
You can add more problems and the script will recognize it. I'm quite sure that this is not exactly what you are looking for, but possibly you can edit the contents of the problems and the execution of math_solver_main.py to your needs.
Upvotes: 1