[code.view]

[top] / python / PyMOTW / abc / abc_abstractproperty_rw_deco.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2009 Doug Hellmann All rights reserved.
     #
     """
     """
     #end_pymotw_header
     
     import abc
     
     class Base(object):
         __metaclass__ = abc.ABCMeta
         
         @abc.abstractproperty
         def value(self):
             return 'Should never see this'
         
         @value.setter
         def value(self, newvalue):
             return
     
     
     class Implementation(Base):
         
         _value = 'Default value'
         
         @property
         def value(self):
             return self._value
     
         @value.setter
         def value(self, newvalue):
             self._value = newvalue
     
     
     i = Implementation()
     print 'Implementation.value:', i.value
     
     i.value = 'New value'
     print 'Changed value:', i.value
     

[top] / python / PyMOTW / abc / abc_abstractproperty_rw_deco.py

contact | logmethods.com