Tree views - Best design practices

MRAB google at mrabarnett.plus.com
Thu Jan 8 11:40:07 EST 2009


Filip Gruszczyński wrote:
>>>>> class Element(object):
>>        operations = "Element operations"
>>
>>
>>>>> class Group(object):
>>        operations = "Group operations"
>>
>>
>>>>> e = Element()
>>>>> g = Group()
>>>>>
>>>>> e.operations
>> 'Element operations'
>>>>> g.operations
>> 'Group operations'
> 
> But this is the same as asking for a class, except for having to write
> a method giving some form of a class name and then basing on this
> classname display operations. I know this solution, but this is what I
> would like to evade.
> 
My point was that the 'operations' attribute could specify the 
operations for that kind of object. More explicitly:

class Element(object):
     operations = [change_properties]

class Group(object):
     operations = [add_element, add_group]


and so on.



More information about the Python-list mailing list