[Python-ideas] Fast sum() for non-numbers

Steven D'Aprano steve at pearwood.info
Sat Jul 6 08:32:47 CEST 2013


On 06/07/13 06:25, Terry Reedy wrote:

> When Alex said that it was not possible to determine if the start value is a number, he was talking in the context of old style classes where the type of every user class was 'Class' and the type of every user instance was 'Instance' (or something like that). In Python 3, with ABCs, isinstance(start, Number) would solve the problem as long as the requirement were documented.


For the record, it has always been possible to check if something is a number:


try:
     x + 0
except TypeError:
     print "x is not a number"



-- 
Steven


More information about the Python-ideas mailing list