New submission from chovey <cho...@sandia.gov>:
We used get/set attribute accessors with private data, and suspect the beaviour we see with the += operator contains a bug. Below is our original implementation, followed by our fix. But, we feel the original implementation should have worked. Please advise. Thank you. @property def position(self) -> np.ndarray: return self._position @position.setter def position(self, val: np.ndarray): self._position = val def update(self, *, delta_t: float): # Nope! Bug! (?) # Tried to combine the getter and setter for self.position # with the += operator, which will not work. # self.position += self.velocity * delta_t # # This fixes the behaviour. self._position = self.velocity * delta_t + self.position ---------- components: 2to3 (2.x to 3.x conversion tool) messages: 402966 nosy: chovey priority: normal severity: normal status: open title: += operator and accessors bug? type: behavior versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue45333> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com