Class-override of a sort-key method?

2010-12-20 Thread pythonlist . calin79
Hi all - it would seem that these days, all the cool kids use the sort function's 'key' kwarg in order to sort a list of custom objects quickly. Unfortunately, as opposed to using 'cmp', where you can implent __cmp__ to get 'automatic sorting' in a similar fashion, there doesn't seem to be a direc

A 'foolproof' way to query inheritance tree? numbers.Real in 2.6)

2010-04-11 Thread pythonlist . calin79
Generally, if I want to know the inheritance tree of a class, I either use inspect.getmro or __bases__ However, after reading about the new numbers module / class tower in Python 2.6/3.0, I realized that both of these will fail to show that the 'float' type actually inherits from numbers.Real: >>