/usr/share/doc/python-traits/examples/tutorials/doc_examples/examples/circular_definition.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 | # Copyright (c) 2007, Enthought, Inc.
# License: BSD Style.
#--[Imports]--------------------------------------------------------------------
from traits.api import HasTraits, Trait, Instance
#--[Code]-----------------------------------------------------------------------
# Shows the incorrect way of defining mutually-referring classes.
try:
class Chicken ( HasTraits ):
# Won't work: 'Egg' not defined yet:
hatched_from = Instance( Egg )
class Egg ( HasTraits ):
# If we move this class to the top, then this line won't work, because
# 'Chicken' won't be defined yet:
created_by = Instance( Chicken )
except NameError, excp:
print excp
|