Python 3.5 有什么新特性?

WBOY
Libérer: 2016-06-06 16:22:57
original
1091 Les gens l'ont consulté

回复内容:

官网就有,何必问?
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>
Copier après la connexion
Python 3.5将支持Async/Await异步编程
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal