/usr/share/doc/python-traits/examples/tutorials/doc_examples/examples/override_default.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 | # Copyright (c) 2007, Enthought, Inc.
# License: BSD Style.
# override_default.py -- Example of overriding a default value for
# a trait attribute in a subclass
#--[Imports]--------------------------------------------------------------------
from traits.api \
import HasTraits, Range, Str
#--[Code]-----------------------------------------------------------------------
# Example of overriding a default value for a trait in a subclass:
# Define the base class:
class Employee ( HasTraits ):
name = Str
salary_grade = Range( value = 1, low = 1, high = 10 )
# Define a subclass:
class Manager ( Employee ):
# Override the default value for the inherited 'salary_grade' trait:
salary_grade = 5
#--[Example*]-------------------------------------------------------------------
# Create an employee and display its initial contents:
joe = Employee( name = 'Joe' )
joe.print_traits()
# Now do the same thing for a manager object:
mike = Manager( name = 'Mike' )
mike.print_traits()
|