Differences between revisions 2 and 3
Revision 2 as of 2004-10-13 02:38:18
Size: 571
Editor: 60
Comment: 元组比较语义 怪怪
Revision 3 as of 2004-10-13 02:39:12
Size: 573
Editor: 60
Comment:
Deletions are marked like this. Additions are marked like this.
Line 23: Line 23:
2 对于空tuple (), 与含有2个或更多元素的tuple比较,cmp( (), (a,b)), 结果为-1,即 () < (a,b) 为真 2  对于空tuple (), 与含有2个或更多元素的tuple比较,cmp( (), (a,b)), 结果为-1,即 () < (a,b) 为真
Line 25: Line 25:
3 对于非空tuple之间的,比较的是元素个数 3  对于非空tuple之间的,比较的是元素个数

python 元组比较语义 怪怪

Example

   1 ()<(1)
   2 (1)<(2)
   3 ()<(1,2)
   4 """result"""
   5 False
   6 True
   7 True

=== 怪怪===

1 对于空tuple (), 与含有一个元素的tuple比较,cmp( (), (a)), 结果为1,即 () > (a) 为真

2  对于空tuple (), 与含有2个或更多元素的tuple比较,cmp( (), (a,b)), 结果为-1,即 () < (a,b) 为真

3 对于非空tuple之间的,比较的是元素个数

第1条的语义与2,3不一致! 没看Python文档, 还不清楚如何定义的.

v-gyc/odd%tuple (last edited 2009-12-25 07:14:44 by localhost)