1 | initial version |
Obviously the Python function should not accept a Sage type.
Why not? Python's abs
calls __abs__
, if it exists:
>>> class NotABuiltinClass(object):
... def __abs__(self):
... return 'fred'
...
>>> a = NotABuiltinClass()
>>> abs(a)
'fred'
The wonders of duck typing. :^)
2 | No.2 Revision |
Obviously the Python function should not accept a Sage type.
Why not? Python's abs
calls __abs__
, if it exists:
>>> class NotABuiltinClass(object):
... def __abs__(self):
... return 'fred'
...
>>> a = NotABuiltinClass()
>>> abs(a)
'fred'
The wonders of duck typing. :^):-)