So in Python you have 3 major tools for code organization…Modules, Classes, & Objects
Python modules are pretty much just a single python file. You can think about it as giving your variables and functions a specific namespace to reference within another python script. For example: The code below imports the contents of "mySampleModule.py" to allow all it's contents to be used in another python script under it's namespace (by default, the filename).
import mySampleModule
To then run a function from this module, you would then write something like this…
mySampleModule.sampleFunction()
or to access a variable within a module…
mySampleModule.sampleVariable
You can also import a module and assign an alias (alternate namespace) like this… allowing code be a bit less bloated. The sample below is the same as the last 3 examples together.
import mySampleModule as msm
msm.sampleFunction()
msm.sampleVariable
A Class is a concept similar to a module, as it can also contain it's own variables and functions. The difference is it allows the user to create multiple instances of “objects”. Conceptually, you can think of this as similar to referencing multiple instances (objects) of a rig (class) within a scene: The rig is referenced from the same file, but you can alter and animate each one differently.
This is a decent reference/tutorial explaining their differences: http://learnpythonthehardway.org/book/ex40.html