/usr/share/doc/python-traits/examples/tutorials/doc_examples/examples/trait_subclass.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 | # Copyright (c) 2007, Enthought, Inc.
# License: BSD Style.
# trait_subclass.py -- Example of subclassing a trait class
#--[Imports]--------------------------------------------------------------------
from traits.api import BaseInt
#--[Code]-----------------------------------------------------------------------
class OddInt ( BaseInt ):
# Define the default value
default_value = 1
# Describe the trait type
info_text = 'an odd integer'
def validate ( self, object, name, value ):
value = super(OddInt, self).validate(object, name, value)
if (value % 2) == 1:
return value
self.error( object, name, value )
|