| 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. :^):-)
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.