庄泽波の博客

好记性不如烂笔头

What's New In Python 3.X

    As Python updating to python 3.6, its performance is better than Python 2.x, which is

good news to every Python developer. I would like to write down new features of Python 3.x,

I hope it can help me remind the history of Python development.

 

1.Python 3.0

1.1 Print Function.

     We need to add bracket when invoking the print() function in Python.

1.2 Views And Iterators Instead of List.

     dict methods dict.keys(), dict.items(). dict.values() return views instead of lists. For example, 

1
keys = d.keys(); keys.sort()

  this no longer works. Use k = sorted(d) instead.

    map() and filter() return iterators.

    range() behaves like xranges() but the latter no longer exists.

    zip() return iterators.

1.3 Ordering Comparisons

   The ordering comparison operators (<, <=, >=, >) raise a TypeError exception when the operands

do not have a meaningful natural ordering. (1 < '', 0 > None order len <= len are no longer valid.)

   builtin.sorted() and list.sort() no longer accept the cmp argument providing a comparison function.

Use the key argument instead.

   The cmp() function should be treated as gone, as the __cmp__() special method is not longer supported.

   

posted on   庄泽波  阅读(174)  评论(0编辑  收藏  举报

编辑推荐:
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 现代计算机视觉入门之:什么是图片特征编码
· .NET 9 new features-C#13新的锁类型和语义
· Linux系统下SQL Server数据库镜像配置全流程详解
阅读排行:
· Sdcb Chats 技术博客:数据库 ID 选型的曲折之路 - 从 Guid 到自增 ID,再到
· 语音处理 开源项目 EchoSharp
· 《HelloGitHub》第 106 期
· Huawei LiteOS基于Cortex-M4 GD32F4平台移植
· mysql8.0无备份通过idb文件恢复数据过程、idb文件修复和tablespace id不一致处

导航

统计信息

点击右上角即可分享
微信分享提示