@@ -125,7 +125,7 @@ argument list. It is called as ::
125
125
126
126
handler(signum, frame)
127
127
128
- so it should be declared with two arguments ::
128
+ so it should be declared with two parameters ::
129
129
130
130
def handler(signum, frame):
131
131
...
@@ -159,9 +159,9 @@ The "global main logic" of your program may be as simple as ::
159
159
160
160
at the bottom of the main module of your program.
161
161
162
- Once your program is organized as a tractable collection of functions and class
163
- behaviours you should write test functions that exercise the behaviours. A test
164
- suite that automates a sequence of tests can be associated with each module.
162
+ Once your program is organized as a tractable collection of function and class
163
+ behaviours, you should write test functions that exercise the behaviours. A
164
+ test suite that automates a sequence of tests can be associated with each module.
165
165
This sounds like a lot of work, but since Python is so terse and flexible it's
166
166
surprisingly easy. You can make coding much more pleasant and fun by writing
167
167
your test functions in parallel with the " production code" , since this makes it
@@ -295,7 +295,7 @@ queue as there are threads.
295
295
How do I parcel out work among a bunch of worker threads?
296
296
---------------------------------------------------------
297
297
298
- The easiest way is to use the new :mod:` concurrent.futures` module,
298
+ The easiest way is to use the :mod:` concurrent.futures` module,
299
299
especially the :mod:` ~concurrent.futures.ThreadPoolExecutor` class.
300
300
301
301
Or, if you want fine control over the dispatching algorithm, you can write
@@ -679,7 +679,7 @@ How can I mimic CGI form submission (METHOD=POST)?
679
679
I would like to retrieve web pages that are the result of POSTing a form. Is
680
680
there existing code that would let me do this easily?
681
681
682
- Yes. Here's a simple example that uses urllib.request::
682
+ Yes. Here's a simple example that uses :mod: ` urllib.request` ::
683
683
684
684
#!/usr/local/bin/python
685
685
@@ -765,20 +765,21 @@ The :mod:`select` module is commonly used to help with asynchronous I/O on
765
765
sockets.
766
766
767
767
To prevent the TCP connect from blocking, you can set the socket to non-blocking
768
- mode. Then when you do the ` ` connect() ` ` , you will either connect immediately
768
+ mode. Then when you do the :meth: ` socket. connect` , you will either connect immediately
769
769
(unlikely) or get an exception that contains the error number as ` ` .errno` ` .
770
770
` ` errno.EINPROGRESS` ` indicates that the connection is in progress, but hasn't
771
771
finished yet. Different OSes will return different values, so you're going to
772
772
have to check what's returned on your system.
773
773
774
- You can use the ` ` connect_ex() ` ` method to avoid creating an exception. It will
775
- just return the errno value. To poll, you can call ` ` connect_ex() ` ` again later
774
+ You can use the :meth: ` socket. connect_ex` method to avoid creating an exception. It will
775
+ just return the errno value. To poll, you can call :meth: ` socket. connect_ex` again later
776
776
-- ` ` 0` ` or ` ` errno.EISCONN` ` indicate that you're connected -- or you can pass this
777
- socket to select to check if it's writable.
777
+ socket to :meth: ` select.select ` to check if it's writable.
778
778
779
779
.. note::
780
- The :mod:` asyncore` module presents a framework-like approach to the problem
781
- of writing non-blocking networking code.
780
+ The :mod:` asyncio` module provides a general purpose single-threaded and
781
+ concurrent asynchronous library, which can be used for writing non-blocking
782
+ network code.
782
783
The third-party ` Twisted < https://twistedmatrix.com/trac/> ` _ library is
783
784
a popular and feature-rich alternative.
784
785
@@ -832,8 +833,8 @@ There are also many other specialized generators in this module, such as:
832
833
833
834
Some higher-level functions operate on sequences directly, such as:
834
835
835
- * ` ` choice(S)` ` chooses random element from a given sequence
836
- * ` ` shuffle(L)` ` shuffles a list in-place, i.e. permutes it randomly
836
+ * ` ` choice(S)` ` chooses a random element from a given sequence.
837
+ * ` ` shuffle(L)` ` shuffles a list in-place, i.e. permutes it randomly.
837
838
838
839
There's also a ` ` Random` ` class you can instantiate to create independent
839
840
multiple random number generators.
0 commit comments