Skip to content

Minor changes in Doc/faq/library. #15449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 9, 2019
Merged

Conversation

awecx
Copy link
Contributor

@awecx awecx commented Aug 24, 2019

A few improvments on faq/library doc page :

  • l. 162 : it should be "function" not "functions" otherwise the "behaviours" only refer to "class", which, I believe, was not intended. Thanks @christopheNan for spotting this.
  • l. 298 : IMO concurrent.futures introduced in 3.2 should not be considered "new" in 3.9 anymore.
  • l. 780 : update reference to deprecated asyncore module.

Copy link
Contributor

@aeros aeros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @awecx!

I some some feedback regarding the changes made:

@@ -125,7 +125,7 @@ argument list. It is called as ::

handler(signum, frame)

so it should be declared with two arguments::
so it should be declared with two parameters::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, a function is called with arguments and declared with parameters.

@@ -295,7 +295,7 @@ queue as there are threads.
How do I parcel out work among a bunch of worker threads?
---------------------------------------------------------

The easiest way is to use the new :mod:`concurrent.futures` module,
The easiest way is to use the :mod:`concurrent.futures` module,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, concurrent.futures is no longer new.

@@ -774,10 +774,10 @@ have to check what's returned on your system.
You can use the ``connect_ex()`` method to avoid creating an exception. It will
just return the errno value. To poll, you can call ``connect_ex()`` again later
-- ``0`` or ``errno.EISCONN`` indicate that you're connected -- or you can pass this
socket to select to check if it's writable.
socket to ``select()`` to check if it's writable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to reference the method itself, a link should be provided to the corresponding documentation with Sphinx roles:

Suggested change
socket to ``select()`` to check if it's writable.
socket to :meth:`select.select` to check if it's writable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, but since "connect_ex()" and "errno.EISCONN" were only highlighted in the previous sentence, I felt I would do the same for "select()". But I agree maybe we should provide a link to those as well.

Copy link
Contributor

@aeros aeros Aug 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, but since "connect_ex()" and "errno.EISCONN" were only highlighted in the previous sentence, I felt I would do the same for "select()".

There's quite a lot of the existing documentation which simply hasn't been updated to use the Sphinx roles, since they're a fairly new addition in comparison. Generally speaking, they are only intentionally not used when the link wouldn't provide readers any additional information, such as when an object is being referred to within it's own definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I have made a new commit where "connect" and "connect_ex" have the link, but not "errno.EISCONN", nor "EISINPROGRESS" as their meaning is already detailed in this doc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I have made a new commit where "connect" and "connect_ex" have the link, but not "errno.EISCONN", nor "EISINPROGRESS" as their meaning is already detailed in this doc.

Just for clarification: Terms on the same doc page can be linked to if they're not defined in the same section (or in a very nearby paragraph), but that's fine.


.. note::
The :mod:`asyncore` module presents a framework-like approach to the problem
The :mod:`asyncio` module presents a framework-like approach to the problem
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asyncore is a separate module from asyncio, see https://docs.python.org/3.5/library/asyncore.html

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course but it is now deprecated and all all its functionnality has been moved to asyncio, hence the proposed update.

Copy link
Contributor

@aeros aeros Aug 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course but it is now deprecated and all all its functionnality has been moved to asyncio, hence the proposed update.

My point was that the two are not exactly one-to-one.

I agree that this section should be updated to recommend asyncio, but the surrounding text should be adjusted a bit as well. Their purposes are similar, but the existing text is more aimed at asyncore. Asyncio is a general purpose concurrency library, whereas asyncore was more of a framework for a specific purpose.

The :mod:`asyncio` module provides a general purpose single-threaded and
concurrent asynchronous library, which can be used for writing non-blocking
network code.

Edit: Slightly improved section update suggestion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK great, I've committed your proposal.

@@ -159,7 +159,7 @@ The "global main logic" of your program may be as simple as ::

at the bottom of the main module of your program.

Once your program is organized as a tractable collection of functions and class
Once your program is organized as a tractable collection of function and class
Copy link
Contributor

@aeros aeros Aug 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this section is okay as it is. I can see where you were going with this though, you might have assumed that the "and" was implying: "... collection of functions behaviors and class behaviors" (which would be grammatically incorrect). But, in this case the two are entirely separate. The "behaviors" part is only connected to "class". The two items are:

  1. Collection of functions
  2. Collection of class behaviors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, I don't understand why the doc states that "you should write test functions that exercise the behaviours". If "behaviours" only applies to "class" and not to "function", then the doc would say that functions not embedded into classes should not be tested. Am I missing something here ?

Copy link
Contributor

@aeros aeros Aug 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If "behaviours" only applies to "class" and not to "function", then the doc would say that functions not embedded into classes should not be tested.

Hmm, good point. I might've been looking at this correction too much in isolation without fully considering the surrounding context. While reading over that sentence a couple of times, I also realized it's missing a comma:

Once your program is organized as a tractable collection of function and class
behaviours, you should write test functions that exercise the behaviours.

Also an interesting tidbit (this is definitely subjective though, so I wouldn't suggest changing it for this PR), but we actually alternate between the American English and British English versions of "behaviors/behaviours" within the documentation:

$ git grep -E "behaviors" -- "*.rst" | wc -l
26
$ git grep -E "behaviours" -- "*.rst" | wc -l
8

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice catch (never occured to me there were two versions of this word). I've added the comma.

awecx and others added 4 commits August 25, 2019 10:54
Co-Authored-By: Kyle Stanley <aeros167@gmail.com>
Co-Authored-By: Kyle Stanley <aeros167@gmail.com>
@aeros
Copy link
Contributor

aeros commented Aug 27, 2019

LGTM with the latest revisions, now we just have to wait for approval from a core developer.

@matrixise matrixise merged commit 88b24f9 into python:master Sep 9, 2019
@bedevere-bot
Copy link

@matrixise: Please replace # with GH- in the commit message next time. Thanks!

@matrixise
Copy link
Member

Thank you for your contribution.

websurfer5 pushed a commit to websurfer5/cpython that referenced this pull request Jul 20, 2020
* Minor changes.

* Update Doc/faq/library.rst

Co-Authored-By: Kyle Stanley <aeros167@gmail.com>

* Apply suggestions from aeros167.

* Update Doc/faq/library.rst

Co-Authored-By: Kyle Stanley <aeros167@gmail.com>

* Apply suggestions from aeros167 + re-add a "a" that was accidentally deleted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants