/usr/share/doc/python-traits/examples/tutorials/doc_examples/examples/prototype_prefix.py is in python-traits 4.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | # Copyright (c) 2007, Enthought, Inc.
# License: BSD Style.
# prototype_prefix.py --- Examples of PrototypedFrom() prefix parameter
#--[Imports]--------------------------------------------------------------------
from traits.api import PrototypedFrom, Float, HasTraits, Instance, Str
#--[Code]-----------------------------------------------------------------------
class Parent (HasTraits):
first_name = Str
family_name = ''
favorite_first_name = Str
child_allowance = Float(1.00)
class Child (HasTraits):
__prefix__ = 'child_'
first_name = PrototypedFrom('mother', 'favorite_*')
last_name = PrototypedFrom('father', 'family_name')
allowance = PrototypedFrom('father', '*')
father = Instance(Parent)
mother = Instance(Parent)
#--[Example*]-------------------------------------------------------------------
fred = Parent( first_name = 'Fred',
family_name = 'Lopez',
favorite_first_name = 'Diego',
child_allowance = 5.0 )
maria = Parent( first_name = 'Maria',
family_name = 'Gonzalez',
favorite_first_name = 'Tomas',
child_allowance = 10.0 )
nino = Child( father=fred, mother=maria )
print '%s %s gets $%.2f for allowance' % (nino.first_name, nino.last_name, nino.allowance)
|