bgen rocks

Chris li chrisl_li at
Wed Jan 8 02:54:50 CET 2003

I recently spend some time on bgen to learn how to
make python modules. bgen is so cool!

It seems that bgen has some ages now. It is still
using the regsub module instead of re.

It is true that bgen lack of documents. The best
one I can find is one of Guido's power point files
back in 1995. Here is google's html version:

The source code in Python/Mac/Modules/* is
very useful also. I think the snd module is a
good example.

Of course, the bgen source file. I think document
bgen to the level that people can read document
to use bgen will take not less than the bgen
source itself. So if you want to hack bgen,
just read the source!

I modify the bgen a little bit to use re module
and also add some ObjectDefinition for generating
C structures objects, of course, reuse the type
we already know.

So the generated get_attr() of that object will
some what look like this:

if (strcmp(name,"member1")==0)
    return Py_BuildValue("i",
self->ob_itself->member1 );
else if (strcmp(name, "member2")==0)
    return Py_BuildValue(...);
    return Py_FindMethodInChain(...)

It works fine. But the memeber can't be list by
dir(). Of course it can't, it is not in the

My question is that, if I want to make the member
able to list by dir(), what is the prefer way?



Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.

More information about the Python-list mailing list