I would like to separate my functions into different files like I do with c++ (a driver file and a file for different categories of functions that I end up linking together upon compilation).
Let’s suppose I want to create a simple ‘driver’ file which launches the main program and a ‘function’ file which includes simple functions which are called by the driver and other functions within the ‘function’ file.
How should I do this? Since python is not compiled, how do I link files together?
You can
importmodules. Simply create different python files and import them at the start of your script.For example I got this
function.pyfile :And this
main.pyfile:And that is it! This is the official tutorial on importing modules.