The Industry choice
Sat Jan 1 19:41:05 EST 2005
beliavsky at aol.com writes:
> Overall I agree with you and would like to have OPTIONAL static type
> declarations in Python, as has often been discussed. But without
> facilities for generic programming, such as templates in C++, static
> type declarations can force one to duplicate a LOT of code, with one
> sorting routine each for integer, floats, strings, etc.
I don't see that big a problem. The current Python sorting routine
operates on instances of class "object" and calls the __cmp__ method
to do comparisons. Every class of sortable objects either defines a
__cmp__ method or inherits one from some superclass, and sort calls
those methods. Static type declarations would not require writing any
additional sorting routines.
More information about the Python-list