A python source file *is* a module. And you import it the same way you import any of the system modules. Just use the basename, without the .py extension.
  import mylib

The only catch is where you locate this module. When you first write it, just put it in the same directory as your scripts, and it'll automatically be found. Then when you're using it from scripts that aren't all located in the same directory, move it to a place on the sys.path. Finally, when you have several related modules, you can make them into a package. A package is a directory located on the path, that contains afiloe wit the special name __init__.py There's some description needed for each of these steps, but just knowing what they are should be enough for now. Besides, the description varies by python version.

The only needs to create a C-based module would be if
    1) performance is an overriding consideration
    2) or it's already written in C
3) or it needs access to some system facility that's not easily available directly from Python. Even then, you probably would write a bit of C "glue," and the rest in Python.

ntwrkd wrote:
I have been browsing through creating a Python module for common
custom functions that I frequently use, but I am wondering, is this
the best method, and is it necessary?
Really all I need is to import functions from another plaintext Python
source file, how might I do this?
What would merit the need to create a C-based Python module?

Thanks in advance

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to