[Python-Dev] Change in evaluation order in new object model (original) (raw)
Thomas Heller thomas.heller@ion-tof.com
Fri, 2 Nov 2001 19:20:31 +0100
- Previous message: [Python-Dev] Change in evaluation order in new object model
- Next message: [Python-Dev] Change in evaluation order in new object model
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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'] slotdocs = {'a':"doc string for a", 'b' : "doc string for b"} slottypes = {'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
- Previous message: [Python-Dev] Change in evaluation order in new object model
- Next message: [Python-Dev] Change in evaluation order in new object model
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]