Python 不同对象比較大小
2024-09-08 06:34:43
万恶的源泉:
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
最新文章
- java基础总结——基础语法2(语句)
- FPGA重要设计思想
- Guava----Function
- [转]恢复 git reset -hard 的误操作
- Stack and Heap 堆和栈的区别
- request.setCharacterEncoding 和常用内置对象 跳转
- R语言实战读书笔记2—创建数据集(上)
- Generate Parentheses java实现
- Lombok 安装
- iOS8新增加的frameworks, 在目前基于7以上开发的情况下, 使用下列sdk要注意设置成optional
- 【转】CString类型互转 int
- iOS新的旅程之Swift语言的学习
- web开发路径问题
- hive表的存储格式; ORC格式的使用
- day 21 - 2 练习
- Linq高级查询,分页查询及查询分页结合
- 五、MongoDB的索引
- localStorage的存储、获取、删除操作
- 八.jQuery源码解析之get()
- python在windows环境安装MySQLdb
热门文章
- webstorm 设置ES6语法支持以及添加vuejs开发配置
- 我能考虑到的数组(老)方法就这些了(es5)
- LINUX:Contos7.0 / 7.2 LAMP+R 下载安装Php篇
- HDU 4747 Mex【线段树上二分+扫描线】
- 集训第五周动态规划 G题 回文串
- UVA 253 Cube painting(枚举 模拟)
- Qt笔记——添加菜单图片/添加资源文件
- intellij idea 忽略文件不提交
- jsp学习之如何在web层创建Servlet
- [BZOJ1264][AHOI2006]基因匹配Match(DP + 树状数组)