Differences between revisions 3 and 5 (spanning 2 versions)
Revision 3 as of 2007-01-14 15:39:38
Size: 1983
Editor: HuangYi
Comment: python3000中最喜欢的三个大变化
Revision 5 as of 2007-04-10 05:00:03
Size: 2077
Editor: HuangYi
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
''' 即将到来的 Python 3000 '''::-- ["swordsp"] [[[DateTime]]] [[TableOfContents]] '''即将到来的 Python 3000 '''::-- ["swordsp"] [[[DateTime]]] [[TableOfContents]]
Line 5: Line 5:
 * [wiki:peps/pep-3000/ PEP 3000] -- Python 3000
 * [wiki:peps/pep-3099/ PEP 3099] -- Things that will Not Change in Python 3000
 * [wiki:peps/pep-3100/ PEP 3100] -- Miscellaneous Python 3.0 Plans
 * [wiki:peps/pep-3104/ PEP 3104] -- Access to Names in Outer Scopes
这算是个老问题了:
{{{#!python
 * [wiki:peps:pep-3000/ PEP 3000] -- Python 3000
 * [wiki:peps:pep-3099/ PEP 3099] -- Things that will Not Change in Python 3000
 * [wiki:peps:pep-3100/ PEP 3100] -- Miscellaneous Python 3.0 Plans
=== PEPs ===
====
Access to Names in Outer Scopes ====
[wiki:peps:pep-3104/ PEP 3104]

  
这算是个老问题了:

  
{{{
#!python
Line 17: Line 22:
而 python3000 中有望通过使用 nonlocal 关键字访问外层名字空间:
{{{#!python
  而 python3000 中有望通过使用 nonlocal 关键字访问外层名字空间:

  
{{{
#!python
Line 26: Line 33:
nonlocal 会从最靠近的名字空间不断向外搜索。   nonlocal 会从最靠近的名字空间不断向外搜索。
Line 28: Line 35:
 * [wiki:peps/pep-3107/ PEP 3107] -- Function Annotations
可以可选地给函数添加元数据,利用这些元数据可以干很多事情,比如文档生、类型检查、方便与静态语言之间的交互等等,看个例子:
{{{#!python
==== Function Annotations ====
[wiki:peps:pep-3107/ PEP 3107]

  
可以可选地给函数添加元数据,利用这些元数据可以干很多事情,比如文档生、类型检查、方便与静态语言之间的交互等等,看个例子:

  
{{{
#!python
Line 34: Line 45:
 * [wiki:peps/pep-3108/ PEP 3108] -- Standard Library Reorganization
重新组织标准库,主要是除和重命名。
==== Standard Library Reorganization ====
[wiki:peps:pep-3108/ PEP 3108]
  
重新组织标准库,主要是除和重命名。
Line 38: Line 50:
Line 45: Line 56:

=== 讨论 ===
[[PageComment2]]

即将到来的 Python 3000 ::-- ["swordsp"] [DateTime] TableOfContents

概述

  • [wiki:peps:pep-3000/ PEP 3000] -- Python 3000
  • [wiki:peps:pep-3099/ PEP 3099] -- Things that will Not Change in Python 3000
  • [wiki:peps:pep-3100/ PEP 3100] -- Miscellaneous Python 3.0 Plans

PEPs

Access to Names in Outer Scopes

[wiki:peps:pep-3104/ PEP 3104]

  • 这算是个老问题了:
       1 a = 1
       2 def test1():
       3     a = 2
       4     def test2():
       5         #目前的python版本中,这里无法修改 test1 中的那个 a。
    
    而 python3000 中有望通过使用 nonlocal 关键字访问外层名字空间:
       1 a = 1
       2 def test1():
       3     a = 2
       4     def test2():
       5         nonlocal a = 3
       6         # 这样就把 test1 中的 a 修改了。
    
    nonlocal 会从最靠近的名字空间不断向外搜索。

Function Annotations

[wiki:peps:pep-3107/ PEP 3107]

  • 可以可选地给函数添加元数据,利用这些元数据可以干很多事情,比如文档生成、类型检查、方便与静态语言之间的交互等等,看个例子:
       1 def foo(a: 'x', b: 5 + 6, c: list) -> max(2, 9):
       2     ...
    

Standard Library Reorganization

[wiki:peps:pep-3108/ PEP 3108]

  • 重新组织标准库,主要是移除和重命名。

进展

讨论

PageComment2

Python3000 (last edited 2009-12-25 07:16:15 by localhost)