[Python-Dev] Change in evaluation order in new object model

Thomas Heller thomas.heller@ion-tof.com
Fri, 2 Nov 2001 19:20:31 +0100


> Andrew described an example of how the descriptor[1] capability will allow 
> Python to be extended in interesting ways.  It turns out to be relatively 
> easy to extend the descriptor capability. I submitted a patch yesterday that 
> adds  support for doc strings and optional type checking to the members 
> defined by slots.  The syntax to add the new capabilities is similar to the 
> __slots__, but uses dictionaries to assign the values.
> 
> class B(object):
>     __slots__ = ['a','b','c']
>     __slot_docs__ = {'a':"doc string for a", 'b' : "doc string for b"}
>     __slot_types__ = {'a':(int,str), 'c':int, }
> 
This is very interesting - I will definitely look at your patch.

This can also be achieved by implementing custom
attribute descriptors, without changes to the core.
You just have to equip the class with them manually.

Currently I'm working on something similar (see http://lpfw.sf.net/, use the
link titled 'Accessing and manipulating C data types').

Thomas