Is it a good idea to make use different Python scripts for programs?
Question: I am wondering if it would be a good idea to use different `.py` scripts for
different parts of a Python program. Like one `.py` file for a calculator and
another for class files and etc. If it is a good idea, is it possible?

If possible, where can I find how to do so?

I am asking this because I find it confusing to have so much code in a single
file, and have to find it anytime fixing is needed.


Answer: If your program starts assuming big dimensions, yes, you could split your
classes or simply your functions according to what they do. Usually functions
that do similar tasks or that work on the same data are put together.

To import a file containing a set of functions that you defined, if the file
is in the same folder where your main script is, you can simply use this
statement, if, for example, the name of the script containing your function
that you want to imported is called `functions.py`, you can simply do `import
functions` or `from functions import *`, or, better, `from functions import
function_1`.

Let's talk about the 3 ways of importing files that I have just mentioned:

_`import functions`_

Here, in order to use one of your functions, for example `foo`, you have to
put the name of the module in front of the name of the function followed by a
`.`:

`functions.foo('this is a string')`

_`from functions import *`_

In this case, you can directly call foo just typing `foo('this is a new method
of importing files')`. `*` means that you have just imported everything from
the module `functions`.

_`from functions import function_1`_

In this last case, you have imported a specific function `function_1` from the
module `functions`, and you can use just the `function_1` from the same
module:

`function_1('I cannot use the function "foo" here, because I did not imported
it')`

