/usr/share/doc/python-traits/examples/tutorials/doc_examples/examples/deferring_notification.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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | # Copyright (c) 2007, Enthought, Inc.
# License: BSD Style.
# deferring_notification.py -- Example of notification with deferring
#--[Imports]--------------------------------------------------------------------
from traits.api import HasTraits, Instance, PrototypedFrom, Str
#--[Code]-----------------------------------------------------------------------
class Parent ( HasTraits ):
first_name = Str
last_name = Str
def _last_name_changed(self, new):
print "Parent's last name changed to %s." % new
class Child ( HasTraits ):
father = Instance( Parent )
first_name = Str
last_name = PrototypedFrom( 'father' )
def _last_name_changed(self, new):
print "Child's last name changed to %s." % new
#--[Example*]-------------------------------------------------------------------
dad = Parent( first_name='William', last_name='Chase' )
# Output: Parent's last name changed to Chase.
son = Child( first_name='John', father=dad )
# Output: Child's last name changed to Chase.
# Change Parent's last_name
dad.last_name='Jones'
# Output: Parent's last name changed to Jones.
# Child's last name changed to Jones.
# Override Child's last_name
son.last_name='Thomas'
# Output Child's last name changed to Thomas.
# Change Parent's last_name; Child's is not affected.
dad.last_name='Riley'
# Output: Parent's last name changed to Riley.
# Reset Child's last_name
del son.last_name
# Output: Child's last name changed to Riley.
# Change to Parent now affects Child.
dad.last_name='Simmons'
# Output: Parent's last name changed to Simmons.
# Child's last name changed to Simmons.
|