Well, a solution is to create a directory to add your modules and add this directory to the Python pat. For example, you can create a directory at, let us say, C:\mypymodules
and put a cls.py
file there with your function.
Now, let us add this directory to the Python path. Follow these instructions, just inserting C:\mypymodules
in place of the directories mentioned there. Now, open a new command line window and try to import the module.
Another solution is to use distutils*. Instead of creating your own modules directory, in the same directory of your cls.py
file create a file named setup.py
with the following content:
from distutils.core import setup
setup(name='cls', py_modules=['cls'])
Then, just execute it:
> python setup.py install
This may install your module in the default Python library directories. Actually, this is the way (or, better yet, one of the ways) to pack, manage or python packages.
(I am not really using Windows, so some details may be broken. Nonetheless, I believe the general concepts are the same.)
* Some may argue about using setuptools but I think it is really overkill for your case. Anyway, if you want to learn more, see this question.