Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
45d22c25
Kaydet (Commit)
45d22c25
authored
Nis 08, 2017
tarafından
Jelle Zijlstra
Kaydeden (comit)
Berker Peksag
Nis 08, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Improvements to typing documentation (#967)
Documents a few omitted classes and adds NamedTuple methods.
üst
b785396a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
7 deletions
+43
-7
typing.rst
Doc/library/typing.rst
+43
-7
No files found.
Doc/library/typing.rst
Dosyayı görüntüle @
45d22c25
...
...
@@ -508,6 +508,14 @@ The module defines the following classes, functions and decorators:
An ABC with one abstract method ``__float__``.
.. class:: SupportsComplex
An ABC with one abstract method ``__complex__``.
.. class:: SupportsBytes
An ABC with one abstract method ``__bytes__``.
.. class:: SupportsAbs
An ABC with one abstract method ``__abs__`` that is covariant
...
...
@@ -658,7 +666,19 @@ The module defines the following classes, functions and decorators:
.. class:: DefaultDict(collections.defaultdict, MutableMapping[KT, VT])
A generic version of :class:`collections.defaultdict`
A generic version of :class:`collections.defaultdict`.
.. class:: Counter(collections.Counter, Dict[T, int])
A generic version of :class:`collections.Counter`.
.. versionadded:: 3.6.1
.. class:: ChainMap(collections.ChainMap, MutableMapping[KT, VT])
A generic version of :class:`collections.ChainMap`.
.. versionadded:: 3.6.1
.. class:: Generator(Iterator[T_co], Generic[T_co, T_contra, V_co])
...
...
@@ -742,9 +762,12 @@ The module defines the following classes, functions and decorators:
This defines the generic type ``IO[AnyStr]`` and aliases ``TextIO``
and ``BinaryIO`` for respectively ``IO[str]`` and ``IO[bytes]``.
These represent
ing
the types of I/O streams such as returned by
These represent the types of I/O streams such as returned by
:func:`open`.
These types are also accessible directly as ``typing.IO``,
``typing.TextIO``, and ``typing.BinaryIO``.
.. class:: re
Wrapper namespace for regular expression matching types.
...
...
@@ -756,6 +779,9 @@ The module defines the following classes, functions and decorators:
``Pattern[str]``, ``Pattern[bytes]``, ``Match[str]``, or
``Match[bytes]``.
These types are also accessible directly as ``typing.Pattern``
and ``typing.Match``.
.. class:: NamedTuple
Typed version of namedtuple.
...
...
@@ -782,10 +808,20 @@ The module defines the following classes, functions and decorators:
Fields with a default value must come after any fields without a default.
The resulting class has two extra attributes: ``_field_types``,
giving a dict mapping field names to types, and ``field_defaults``, a dict
giving a dict mapping field names to types, and ``
_
field_defaults``, a dict
mapping field names to default values. (The field names are in the
``_fields`` attribute, which is part of the namedtuple API.)
``NamedTuple`` subclasses can also have docstrings and methods::
class Employee(NamedTuple):
"""Represents an employee."""
name: str
id: int = 3
def __repr__(self) -> str:
return f'<Employee {self.name}, id={self.id}>'
Backward-compatible usage::
Employee = NamedTuple('Employee', [('name', str), ('id', int)])
...
...
@@ -794,7 +830,7 @@ The module defines the following classes, functions and decorators:
Added support for :pep:`526` variable annotation syntax.
.. versionchanged:: 3.6.1
Added support for default values.
Added support for default values
, methods, and docstrings
.
.. function:: NewType(typ)
...
...
@@ -972,9 +1008,9 @@ The module defines the following classes, functions and decorators:
:data:`ClassVar` is not a class itself, and should not
be used with :func:`isinstance` or :func:`issubclass`.
Note that :data:`ClassVar` does not change Python runtime behavior;
it can be used by
3rd party type checkers, so that the following
code might flagged as an error by those
::
:data:`ClassVar` does not change Python runtime behavior, but
it can be used by
third-party type checkers. For example, a type checker
might flag the following code as an error
::
enterprise_d = Starship(3000)
enterprise_d.stats = {} # Error, setting class variable on instance
...
...
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