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
Considering Python's duck-typing semantics, it'd be really useful if it were possible to define custom 'special functions' (like __add__, __str__, etc) on ProxyObject, in order to build custom objects that mesh nicely with the rest of Python.
Defining these methods is currently possible, but Python doesn't pick them up properly. For instance, consider the following code (pardon the Clojure ;)):
1 2 hi
<foreign object at 0x67b613f9>
AttributeError: foreign object has no attribute '__len__'
TypeError: unsupported operand type(s) for +: 'foreign' and 'int'
The text was updated successfully, but these errors were encountered:
Am I reading this correctly that you create an object with a property __len__? In that case, this is expected and according to Python semantics. Consider this:
Considering Python's duck-typing semantics, it'd be really useful if it were possible to define custom 'special functions' (like
__add__
,__str__
, etc) on ProxyObject, in order to build custom objects that mesh nicely with the rest of Python.Defining these methods is currently possible, but Python doesn't pick them up properly. For instance, consider the following code (pardon the Clojure ;)):
The expected output here should be
but in reality, what we get is:
The text was updated successfully, but these errors were encountered: