Declaratively setting Property value in a subclass definition
Is if possible to declaratively set the value of Property trait in a
subclass of a HasTraits object *and* trigger the setter for that property?
The example below prints '0' when I would like it to print '10'. You can
see that it uses the getter because it prints 'got here' (post
instantiation), but not the setter (at class definiton, perhaps this is
impossible even with traits metaclass magic!).
# start code
_i = Int
i = Property(Int)
def _set_i(self, i):
self._i = i * 10
print 'got here'
i = 1
t = Test()
# end code
# start output
# end output
I would like to be able to do this because then I can define subclasses
that set some traits which can be then overwritten at instantiation,
rather than repeatedly creating instances with the same values.
My real use case is that I have a List(Instance) trait that I want to be
able to receive a list, a single instance or a list of lists, which
could be defined in a subclass.
I need the setter to be used in order to flatten the list of lists or
wrap the single instance in a list.