|
|||
|
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 > > |
|
|
||||
|
||||
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| RE: Introducing Python to others | Sells, Fred | Newsgroup comp.lang.python | 0 | 04-02-2009 05:07 PM |
| Name suggestions for perl logging module | cdc150@gmail.com | Newsgroup comp.lang.perl.modules | 3 | 04-02-2009 12:03 AM |
| Creating a Python Module - Available Implementations | ntwrkd | Newsgroup comp.lang.python | 0 | 04-01-2009 05:03 PM |
| Re: create a log level for python logging module | dj | Newsgroup comp.lang.python | 4 | 03-31-2009 09:38 PM |
| Re: create a log level for python logging module | Vinay Sajip | Newsgroup comp.lang.python | 0 | 03-30-2009 09:18 PM |