萬惡的源泉:
Fireboo的疑問(當然 lambda 本身寫的就有問題):
>>> filter( lambda x: x > 2, [ 1, [ 1, 2, 3 ], 2, 3 ] ) [[1, 2, 3], 3]
?:
>>> 1 < [ 1 ] True >>> int < list True >>> dict < int < list True
>>> int < map False
后來幾經周折,和 Fireboo 討論了下,是
1.不同對象比較(除了 number 之外),是按照 type names 比較,
2.當相同類型對象不支持適當比較的時候,采用 address 比較
3.list 與 list, tuple 與 tuple 采用字典序比較
>>> x = 1 >>> y = [ 1 ] >>> type( x ) <type 'int'> >>> type( y ) <type 'list'> >>> x < y True
>>> type( int ) <type 'type'> >>> type( list ) <type 'type'> >>> id( int ) 505552912 >>> id( list ) 505555336 >>> int < list True
>>> type( map ) <type 'builtin_function_or_method'> >>> type( list ) <type 'type'> >>> map < list True
新聞熱點
疑難解答