/usr/share/doc/python-traits/examples/tutorials/doc_examples/examples/interface_implementation.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 | # Copyright (c) 2007, Enthought, Inc.
# License: BSD Style.
# interface_implementation.py - Example of implementing an interface
#--[Imports]--------------------------------------------------------------------
from traits.api import HasTraits, implements, Str, Instance
from interface_definition import IName
#--[Code]-----------------------------------------------------------------------
class Person(HasTraits):
implements(IName)
first_name = Str( 'John' )
last_name = Str( 'Doe' )
# Implementation of the 'IName' interface:
def get_name ( self ):
""" Returns the name of an object. """
return ('%s %s' % ( self.first_name, self.last_name ))
#--[Example*]-------------------------------------------------------------------
class Apartment(HasTraits):
renter = Instance(IName)
william = Person(first_name='William', last_name='Adams')
apt1 = Apartment( renter=william )
print 'Renter is: ', apt1.renter.get_name()
# Result: Renter is: William Adams
|