Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
695080d0
Commit
695080d0
authored
Sep 13, 2016
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add text about PEP 526 to What's new in 3.6. Ivan L.
parent
7098b757
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
1 deletion
+37
-1
Doc/whatsnew/3.6.rst
Doc/whatsnew/3.6.rst
+37
-1
No files found.
Doc/whatsnew/3.6.rst
View file @
695080d0
...
...
@@ -72,7 +72,7 @@ New syntax features:
* PEP 515: Underscores in Numeric Literals
* PEP 526:
Syntax for Variable Annotations
* PEP 526:
:ref:`Syntax for Variable Annotations <variable-annotations>`
* PEP 525: Asynchronous Generators
...
...
@@ -277,6 +277,42 @@ evaluated at run time, and then formatted using the :func:`format` protocol::
See :pep:`498` and the main documentation at :ref:`f-strings`.
.. _variable-annotations:
PEP 526: Syntax for variable annotations
========================================
:pep:`484` introduced standard for type annotations of function parameters,
a.k.a. type hints. This PEP adds syntax to Python for annotating the
types of variables including class variables and instance variables::
primes: List[int] = []
captain: str # Note: no initial value!
class Starship:
stats: Dict[str, int] = {}
Just as for function annotations, the Python interpreter does not attach any
particular meaning to variable annotations and only stores them in a special
attribute ``__annotations__`` of a class or module.
In contrast to variable declarations in statically typed languages,
the goal of annotation syntax is to provide an easy way to specify structured
type metadata for third party tools and libraries via the abstract syntax tree
and the ``__annotations__`` attribute.
.. seealso::
:pep:`526` -- Syntax for variable annotations.
PEP written by Ryan Gonzalez, Philip House, Ivan Levkivskyi, Lisa Roach,
and Guido van Rossum. Implemented by Ivan Levkivskyi.
Tools that use or will use the new syntax:
`mypy <http://github.com/python/mypy>`_,
`pytype <http://github.com/google/pytype>`_, PyCharm, etc.
.. _pep-529:
PEP 529: Change Windows filesystem encoding to UTF-8
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment