You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In O'Reilly's book, Python Cookbook (4th edition?), there is an article by Dave Beazley that implements a state machine using delegation. The technique described modifies __class__ of the various state objects. This works fine in CPython but does not work in uPython. The article does state
Object-oriented purists might be offended by the idea of simply changing the instance __class__ attribute. However, it’s technically allowed. Also, it might result in slightly faster code since all of the methods on the connection no longer involve an extra delegation step.
Will this uPy behavior remain or will modification of __class__ be implemented at some point?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In O'Reilly's book, Python Cookbook (4th edition?), there is an article by Dave Beazley that implements a state machine using delegation. The technique described modifies
__class__
of the various state objects. This works fine in CPython but does not work in uPython. The article does stateWill this uPy behavior remain or will modification of
__class__
be implemented at some point?Beta Was this translation helpful? Give feedback.
All reactions