mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-40066: Enum: modify repr()
and str()
(GH-22392)
* Enum: streamline repr() and str(); improve docs - repr() is now ``enum_class.member_name`` - stdlib global enums are ``module_name.member_name`` - str() is now ``member_name`` - add HOW-TO section for ``Enum`` - change main documentation to be an API reference
This commit is contained in:
parent
51a85ddce8
commit
b775106d94
19 changed files with 2225 additions and 1491 deletions
1874
Doc/library/enum.rst
1874
Doc/library/enum.rst
File diff suppressed because it is too large
Load diff
|
@ -35,7 +35,7 @@ associated messages through the :class:`http.HTTPStatus` enum:
|
|||
|
||||
>>> from http import HTTPStatus
|
||||
>>> HTTPStatus.OK
|
||||
<HTTPStatus.OK: 200>
|
||||
HTTPStatus.OK
|
||||
>>> HTTPStatus.OK == 200
|
||||
True
|
||||
>>> HTTPStatus.OK.value
|
||||
|
@ -45,7 +45,7 @@ associated messages through the :class:`http.HTTPStatus` enum:
|
|||
>>> HTTPStatus.OK.description
|
||||
'Request fulfilled, document follows'
|
||||
>>> list(HTTPStatus)
|
||||
[<HTTPStatus.CONTINUE: 100>, <HTTPStatus.SWITCHING_PROTOCOLS: 101>, ...]
|
||||
[HTTPStatus.CONTINUE, HTTPStatus.SWITCHING_PROTOCOLS, ...]
|
||||
|
||||
.. _http-status-codes:
|
||||
|
||||
|
|
|
@ -785,9 +785,9 @@ The :mod:`socket` module also offers various network-related services:
|
|||
system if IPv6 isn't enabled)::
|
||||
|
||||
>>> socket.getaddrinfo("example.org", 80, proto=socket.IPPROTO_TCP)
|
||||
[(<AddressFamily.AF_INET6: 10>, <SocketType.SOCK_STREAM: 1>,
|
||||
[(socket.AF_INET6, socket.SOCK_STREAM,
|
||||
6, '', ('2606:2800:220:1:248:1893:25c8:1946', 80, 0, 0)),
|
||||
(<AddressFamily.AF_INET: 2>, <SocketType.SOCK_STREAM: 1>,
|
||||
(socket.AF_INET, socket.SOCK_STREAM,
|
||||
6, '', ('93.184.216.34', 80))]
|
||||
|
||||
.. versionchanged:: 3.2
|
||||
|
|
|
@ -2062,7 +2062,7 @@ to speed up repeated connections from the same clients.
|
|||
:attr:`SSLContext.verify_flags` returns :class:`VerifyFlags` flags:
|
||||
|
||||
>>> ssl.create_default_context().verify_flags # doctest: +SKIP
|
||||
<VerifyFlags.VERIFY_X509_TRUSTED_FIRST: 32768>
|
||||
ssl.VERIFY_X509_TRUSTED_FIRST
|
||||
|
||||
.. attribute:: SSLContext.verify_mode
|
||||
|
||||
|
@ -2074,7 +2074,7 @@ to speed up repeated connections from the same clients.
|
|||
:attr:`SSLContext.verify_mode` returns :class:`VerifyMode` enum:
|
||||
|
||||
>>> ssl.create_default_context().verify_mode
|
||||
<VerifyMode.CERT_REQUIRED: 2>
|
||||
ssl.CERT_REQUIRED
|
||||
|
||||
.. index:: single: certificates
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue