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,

 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.

What's New In Python 3.X的更多相关文章

  1. Python中的多进程与多线程(一)

    一.背景 最近在Azkaban的测试工作中,需要在测试环境下模拟线上的调度场景进行稳定性测试.故而重操python旧业,通过python编写脚本来构造类似线上的调度场景.在脚本编写过程中,碰到这样一个 ...

  2. Python高手之路【六】python基础之字符串格式化

    Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[PEP-3101] This ...

  3. Python 小而美的函数

    python提供了一些有趣且实用的函数,如any all zip,这些函数能够大幅简化我们得代码,可以更优雅的处理可迭代的对象,同时使用的时候也得注意一些情况   any any(iterable) ...

  4. JavaScript之父Brendan Eich,Clojure 创建者Rich Hickey,Python创建者Van Rossum等编程大牛对程序员的职业建议

    软件开发是现时很火的职业.据美国劳动局发布的一项统计数据显示,从2014年至2024年,美国就业市场对开发人员的需求量将增长17%,而这个增长率比起所有职业的平均需求量高出了7%.很多人年轻人会选择编 ...

  5. 可爱的豆子——使用Beans思想让Python代码更易维护

    title: 可爱的豆子--使用Beans思想让Python代码更易维护 toc: false comments: true date: 2016-06-19 21:43:33 tags: [Pyth ...

  6. 使用Python保存屏幕截图(不使用PIL)

    起因 在极客学院讲授<使用Python编写远程控制程序>的课程中,涉及到查看被控制电脑屏幕截图的功能. 如果使用PIL,这个需求只需要三行代码: from PIL import Image ...

  7. Python编码记录

    字节流和字符串 当使用Python定义一个字符串时,实际会存储一个字节串: "abc"--[97][98][99] python2.x默认会把所有的字符串当做ASCII码来对待,但 ...

  8. Apache执行Python脚本

    由于经常需要到服务器上执行些命令,有些命令懒得敲,就准备写点脚本直接浏览器调用就好了,比如这样: 因为线上有现成的Apache,就直接放它里面了,当然访问安全要设置,我似乎别的随笔里写了安全问题,这里 ...

  9. python开发编译器

    引言 最近刚刚用python写完了一个解析protobuf文件的简单编译器,深感ply实现词法分析和语法分析的简洁方便.乘着余热未过,头脑清醒,记下一点总结和心得,方便各位pythoner参考使用. ...

  10. 关于解决python线上问题的几种有效技术

    工作后好久没上博客园了,虽然不是很忙,但也没学生时代闲了.今天上博客园,发现好多的文章都是年终总结,想想是不是自己也应该总结下,不过现在还没想好,等想好了再写吧.今天写写自己在工作后用到的技术干货,争 ...

随机推荐

  1. 半吊子的STM32 — IIC通信

    半双工通信模式:以字节模式发送(8位): 两线式串行总线,SDA(数据信号)和SCL(时钟信号)两条信号线都为高电平时,总线为空闲状态:起始时,SCL稳定为高电平,SDA电平由高向低跳变:停止时,SC ...

  2. 学习knockoutjs轻量级的MVVM框架

    教程:knockoutjs介绍 http://www.w3cfuns.com/forum.php?mod=viewthread&tid=5598714 MVVM架构~knockoutjs实现简 ...

  3. PHP Jquery 代码操作 内容 属性 样式 事件 Json数据

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  4. vxlan vs GRE(三层组播和二层组播如何对应起来)

    www.huawei.com/ilink/cnenterprise/download/HW_401028 http://feisky.xyz/sdn/basic/vxlan.html 华为的vxlan ...

  5. 搭建http静态网页服务器出现“Forbidden You don't have permission to access / on this server”

    部分参考链接: 2.4+ httpd最简单example.conf, 存放目录:/etc/httpd/conf.d/example.conf Alias /newstart-zte/ "/n ...

  6. djiango控制语句

    {# 从0开始的索引#} {% for foo in value %} {# 从0开始的索引#} <p>{{ forloop.counter0 }}: {{ foo }}</p> ...

  7. json ubuntu下安装

    1.首先安装scons scons是linux下的自动构建工具,类似cmake. 下载地址wget http://prdownloads.sourceforge.net/scons/scons-2.2 ...

  8. PLSQL数组

    declare type t_varchar_arr is TABLE OF varchar2(60); type t_number_arr is TABLE OF number; v_date t_ ...

  9. linux文件系统问题:wrong fs type, bad option, bad superblock

    http://blog.itpub.net/26006637/viewspace-1059946/ 报错内容: mount: wrong fs type, bad option, bad superb ...

  10. canvas 实现烟花效果

    一:创建画布 <canvas width="600" height="600" id="canvas" style="bor ...