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)

包括以下内容: 

转载于:https://www.cnblogs.com/cwgk/p/4446090.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值