* [EMAIL PROTECTED] <[EMAIL PROTECTED]> [2008-02-22 01:42]: > > What, it wasn't obvious in the twisted maze of Python documentation? :) > > > > http://www.python.org/doc/2.4.4/ref/customization.html > > *gag* Yes, this is pretty convoluted. I think I finally managed to > figure some of the object protocol out, though. > > The dbm module implements PyMappingMethods and that defines mp_length, > essentially __len__(). However, this object would need to also > implement PyNumberMethods, which contains an: > > inquiry nb_nonzero; > > structure member. (Implementing __nonzero__) Since it doesn't implement > the number protocol, it's always going to fallback to using __len__, as > you observed. > > These are the prototypes for inquiry and PyMappingMethods. All of this > is in /usr/include/python2.4/object.h > > typedef int (*inquiry)(PyObject *); > > typedef struct { > inquiry mp_length; > binaryfunc mp_subscript; > objobjargproc mp_ass_subscript; > } PyMappingMethods; > > Hopefully some of this makes sense. :P
As Dan pointed out: if only one of you had a blog... - Stephen -- [EMAIL PROTECTED] http://blogs.sun.com/sch/ _______________________________________________ pkg-discuss mailing list [email protected] http://mail.opensolaris.org/mailman/listinfo/pkg-discuss
