Boiler plate method for Module
Skip Montanaro
skip at mojam.com
Wed Sep 15 09:43:29 EDT 1999
Jacques> Hi am looking for a good but simple example of how to write my
Jacques> own Python Object in C
Jacques> 1) Must show me how to write the constructor/destructor
Jacques> 2) Sow me how to do getattr/setattr pair
Jacques> PLEASE DO NOT TELL ME TO LOOK AT TO SOURCE OF PYTHON, I HAVE
Jacques> DONE THAT I JUST WANT TO SEE SIMPLE LAYOUT.
What source did you look at? There are hardly any better examples of what
you are looking for than the actual, functioning source code. Here are the
places I recommend you look:
1. The Extending and Embedding Manual - find a pointer at
http://www.python.org/doc/.
2. Modules/xxmodule.c in the source distribution - a skeleton module that
outlines all the necessary bits and pieces. There's even a stub xxmodule
line in Modules/Setup.
3. Any of a number of actual modules in the Modules directory:
* dbmmodule.c is a pretty simple example of a module that creates an
object and has to have allocation/deallocation methods, and to define
both module methods and object methods.
* soundex.c is a very simple example of a module that doesn't need to
create any objects. It just wraps a simple algorithm.
If you can't fathom the contents of the documentation or the source code to
simple modules, you're probably better off looking for a consultant to hire.
Skip Montanaro | http://www.mojam.com/
skip at mojam.com | http://www.musi-cal.com/~skip/
847-971-7098 | Python: Programming the way Guido indented...
More information about the Python-list
mailing list