Loading

Paste #ptz1ffrui

  1. class Expression(object):
  2.     ....
  3.  
  4. +    def __setattr__(self, name, value):
  5. +        """
  6. +        Protect expression objects from being modified, so they can be safely shared, in particular in L{Expression.reduce}.
  7. +        """
  8. +        raise AttributeError("Not allowed to set \"{}\"".format(name))
  9. +
  10. +    def set_value(self, name, value):
  11. +        """
  12. +        Set a variable to a value. Should only be used in constructors to preserve sharable property of the objects.
  13. +
  14. +        @param name: Name of the attribute to set.
  15. +        @type  name: C{str}
  16. +
  17. +        @param value: New value of the attribute.
  18. +        @type  value: anything
  19. +        """
  20. +        object.__setattr__(self, name, value)

Comments