Python 3.5 有什么新特性?

WBOY
發布: 2016-06-06 16:22:57
原創
1090 人瀏覽過

回复内容:

官网就有,何必问?
Python Release Python 3.5.0a3
Python 3.5.0a3

Python 3.5.0a3 was released on March 30th, 2015.


Major new features of the 3.5 series, compared to 3.4

Python 3.5 is still in development, and 3.5.0a1 is the second alpha release. Many new features are still being planned and written. Among the new major new features and changes in the 3.4 release series so far are

  • PEP 461, adding support for "%-formatting" for bytes and bytearray objects
  • PEP 465, a new operator (@) for matrix multiplication
  • PEP 475, adding support for automatic retries of interrupted system calls
  • PEP 471, os.scandir()
本回答至少在很多地方有错误 详情python 3.5 中 PEP0484 新加入的 Type Hints 的使用方法是什么? - 酿泉的回答

怒答,今天看到,昨天发布的,Python 3.5b1 有类型检查模块了!
以前有 mypy,现在终于是官方的了!def fuck(x: Fuck) -> Fuck 这种语法以前唯一的意义在能让 PyCharm 补全

Python Release Python 3.5.0b1
PEP 484, the typing module, a new standard for type annotations
好爽,好爽,狂喜乱舞中!

这一刻,TypeScript Flow TypedRacket 灵魂附体!现在 Python 某种程度上能同时享受静态类型语言的安全和动态类型语言的灵活性了,某种程度。

正在看 PEP 0484 -- Type Hints

<code class="language-python"><span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">TypeVar</span><span class="p">,</span> <span class="n">Iterable</span><span class="p">,</span> <span class="n">Tuple</span>

<span class="n">T</span> <span class="o">=</span> <span class="n">TypeVar</span><span class="p">(</span><span class="s">'T'</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">,</span> <span class="nb">complex</span><span class="p">)</span>
<span class="n">Vector</span> <span class="o">=</span> <span class="n">Iterable</span><span class="p">[</span><span class="n">Tuple</span><span class="p">[</span><span class="n">T</span><span class="p">,</span> <span class="n">T</span><span class="p">]]</span>

<span class="k">def</span> <span class="nf">inproduct</span><span class="p">(</span><span class="n">v</span><span class="p">:</span> <span class="n">Vector</span><span class="p">)</span> <span class="o">-></span> <span class="n">T</span><span class="p">:</span>
    <span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">y</span> <span class="k">for</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="ow">in</span> <span class="n">v</span><span class="p">)</span>
</code>
登入後複製
Python 3.5将支持Async/Await异步编程
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板