XiaoKL学Python(C)__future__
__future__ in Python
1. from __future__ import xxxx
这是为了在低版本的python中使用可能在某个高版本python中成为语言标准的特性,从而
在将代码由低版本迁移到高版本的过程中,减少需要做的工作。
这种语句被称为 future_statement
2. future_statement的语法定义: Ref[2]
future_statement: "from" "__future__" "import" feature ["as" name]
("," feature ["as" name])* feature: identifier
name: identifier
3. 使用future_statement的注意事项
Reference
1. What is __future__ in Python used for and how/when to use it, and how it works
http://stackoverflow.com/questions/7075082/what-is-future-in-python-used-for-and-how-when-to-use-it-and-how-it-works
2. PEP 236 - PEP 236 -- Back to the __future__
https://www.python.org/dev/peps/pep-0236/
3. 28.11. __future__ — Future statement definitions
https://docs.python.org/2/library/__future__.html
4. Supporting Python 2 and 3 without 2to3 conversion
http://python3porting.com/noconv.html (Porting to Python 3)
http://pypi.python.org/pypi/six
5. http://python-future.org/imports.html (To Read)
包括以下内容:
- absolute_import: PEP 328: Imports: Multi-Line and Absolute/Relative
- division: PEP 238: Changing the Division Operator
- print_function: PEP 3105: Make print a function
- unicode_literals: PEP 3112: Bytes literals in Python 3000
XiaoKL学Python(C)__future__的更多相关文章
- XiaoKL学Python(D)argparse
该文以Python 2为基础. 1. argparse简介 argparse使得编写用户友好的命令行接口更简单. argparse知道如何解析sys.argv. argparse 模块自动生成 “帮助 ...
- XiaoKL学Python(E)Generator Expressions
在 阅读 https://github.com/vitonzhang/objc_dep 中的 objc_dep.py 时遇到: objc_files = (f for f in files if f. ...
- 【Python五篇慢慢弹】快速上手学python
快速上手学python 作者:白宁超 2016年10月4日19:59:39 摘要:python语言俨然不算新技术,七八年前甚至更早已有很多人研习,只是没有现在流行罢了.之所以当下如此盛行,我想肯定是多 ...
- python的__future__特性
使用python的__future__特性, __future__是在旧版本的python中提供了新版python的特性. 1) 在python2中相除返回浮点数,在python3中默认返回浮点数 & ...
- <-0基础学python.第一课->
初衷:我电脑里面的歌曲很久没换了,我想听一下新的歌曲,把他们下载下来听,比如某个榜单的,但是一首一首的点击下载另存为真的很恶心 所以我想有没有办法通过程序的方式来实现,结果还真的有,而且网上已经有有人 ...
- 学Python后到底能干什么?
Python是一种什么语言? Python是一种计算机程序设计语言.你可能已经听说过很多种流行的编程语言,比如非常难学的C语言,非常流行的Java语言,适合初学者的Basic语言,适合网页编程的Jav ...
- 【跟我一起学Python吧】python with statement 进阶理解
由于之前有一个项目老是要打开文件,然后用pickle.load(file),再处理...最后要关闭文件,所以觉得有点繁琐,代码也不简洁.所以向python with statement寻求解决方法.以 ...
- 关于智普 - 千人免费学|Python培训|国内最权威python培训|html5
关于智普 - 千人免费学|Python培训|国内最权威python培训|html5 智普教育隶属于北京顶嵌开源科技有限公司,成立于2008年. 智普开源是基于Linux系统的互联网开源学习平台,讲求务 ...
- [置顶] 和孩子们一起学Python编程
1. 推荐书名 Computer Programming for Kids and Other Beginners in Python, 4Ed.pdf 中文译名:<和孩子们一起学Pyt ...
随机推荐
- selenium自动化测试安装,浏览器驱动版本对应
- js 生成随机颜色
var getRandomColor = function(){ return '#'+(Math.random()*0xffffff<<0).toString(16); } <&l ...
- 服务器安装pip
1. wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6. ...
- SVN 不显示状态图标--解决方法
[SVN 不显示状态图标--解决方法] 在名字前面加空格, 三个六个空格随意: 参考:https://www.cnblogs.com/lzpong/p/6187366.html
- EF CodeFirst学习笔记003--如何创建表
参考: http://www.cnblogs.com/Wayou/archive/2012/09/20/EF_CodeFirst.html webconfig中修改: <connectionSt ...
- JVisual 相关help参数
The launcher has determined that the parent process has a console and will reuse it for its own cons ...
- 五:python 对象类型详解二:字符串(上)
一:常量字符串 常量字符串用起来相对简单,也许最复杂的事情就是在代码中有如此多的方法来编写它们. eg:单引号:'spam"m' , 双引号: “spa'm” , 三引号:‘’‘... ...
- es快照定时备份脚本
#!/bin/bashdata1=`date "+%Y%m%d"`data2="http://0.0.0.0:9200/_snapshot/my_backup/snaps ...
- elasticsearch 不同集群数据同步
采用快照方式 1.源集群采用NFS,注意权限 2.共享目录完成后,在所有ES服务器上挂载为同一目录 3.创建快照仓库 put _snapshot/my_backup{ "type" ...
- vue, js 正则邮箱验证、匹配非法字符、匹配中文
验证邮箱 let self = this let regEmail= /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)* ...