]> granicus.if.org Git - python/commitdiff
Doc: Use walrus operator in example. (GH-15934)
authorJulien Palard <julien@palard.fr>
Wed, 11 Sep 2019 13:01:18 +0000 (15:01 +0200)
committerStéphane Wirtel <stephane@wirtel.be>
Wed, 11 Sep 2019 13:01:18 +0000 (15:01 +0200)
Doc/library/http.client.rst

index 48bc35ca76cc07b3be22703f4db9a2ab8b49a01f..db26d56af30fb4aa2087df73060ede1f130038ba 100644 (file)
@@ -516,10 +516,7 @@ Here is an example session that uses the ``GET`` method::
    >>> # The following example demonstrates reading data in chunks.
    >>> conn.request("GET", "/")
    >>> r1 = conn.getresponse()
-   >>> while True:
-   ...     chunk = r1.read(200)  # 200 bytes
-   ...     if not chunk:
-   ...          break
+   >>> while chunk := r1.read(200):
    ...     print(repr(chunk))
    b'<!doctype html>\n<!--[if"...
    ...