![](https://secure.gravatar.com/avatar/b52011045c2c77d09101e5fe29a14f4f.jpg?s=120&d=mm&r=g)
Trying to handle the sudden change of state of an instance of an object - a "quantum instance" c starts as a Circle instance. Say, in the course of the manipulation of c its radius approaches towards infinity, and upon the radius becoming > than some Max, I want c to suddenly think of itself as a Line instance rather than as a Circle instance. doable? hints? Art
![](https://secure.gravatar.com/avatar/35eca8411b3624637c55a64c4ce1f776.jpg?s=120&d=mm&r=g)
Arthur wrote:
Trying to handle the sudden change of state of an instance of an object - a "quantum instance"
c starts as a Circle instance.
Say, in the course of the manipulation of c its radius approaches towards infinity, and upon the radius becoming > than some Max, I want c to suddenly think of itself as a Line instance rather than as a Circle instance.
doable?
hints?
Art
As a sketch: class Blended(object): MaxRadius = 123456 def __init__(self, radius): self._active = Circle(radius=radius) self._other = Line() self.radius = radius # Switch to Line if necessary def __getattr__(self, name): return getattr(self._active, name) def __setattr__(self, name, value): if name[0] == '_': object.__setattr__(self, name, value) elif name[0] != 'radius': return setattr(self, value) if value < self.MaxRadius: if isinstance(self._active, Line): self._active, self._other = self._other, self._active else: if isinstance(self._active, Circle): self._active, self._other = self._other, self._active self._active.radius = value You could read up on __getattr__, __getattribute__, and friends in the Language References section 3.3.2: Customizing attribute access --Scott David Daniels Scott.Daniels@Acm.Org
![](https://secure.gravatar.com/avatar/6250399551fa01ea94cac0824ec09f33.jpg?s=120&d=mm&r=g)
Say, in the course of the manipulation of c its radius approaches towards infinity, and upon the radius becoming > than some Max, I want c to suddenly think of itself as a Line instance rather than as a Circle instance.
Footnote: In Fuller's synergetic geometry, circles don't become infinite lines, but just bigger and bigger circles. Lines that appear locally straight are just that: local. Clearly we're starting with different assumptions than those of Euclidean greek metaphysics. More from Democritus. Lines aren't perfectly straight either -- zoom in and they become zig-zaggy/wavilinear. Zoom out, and all you get are curves and great circles. Kirby
participants (3)
-
Arthur
-
Kirby Urner
-
Scott David Daniels