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
shutil.which() docstring could be clearer #59353
Comments
I find this a little hard to parse (ignoring the obvious typo and the grammar error): """ One other suggestion: wouldn't 'file' read better as 'command'? |
New changeset 5975292ddf82 by Alexander Belopolsky in branch 'default': |
*file* is correct because shutil.which() is more general than shell which command. (It can be used to find source files on PYTHONPATH, for example.) I think the confusing part is "return the path ... on the path." This can be fixed in reST by marking the second "path" as the argument, but the docstring should be rephrased. Note that reST documentation for shutil.which() is missing in Doc/library/shutil.rst. |
I updated file to command in 973b4806f760. It needs to be command so it matches the implementation's argument name, and because it doesn't exactly take a file. Alexander, can you explain the part about finding a file on PYTHONPATH? I don't think this has anything to do with shutil.which, or at least I have no idea how it would. |
I thought about something like this: >>> shutil.which('shutil.py', os.F_OK, ':'.join(sys.path))
'/Users/sasha/Work/python-hg/py3k/Lib/shutil.py' but win32 code seems to assume a search for a command. |
Brian, Did you intend to commit Tools/msi/msi.py in changeset 973b4806f760? |
No, reverting. |
Yeah, Brian had it as 'file' before, and I asked him to change it because it is confusing. 'file' sounds like a Python file object, which this is not. 'filename' would be OK, but 'cmd', as you note, is what it is really about. One possibility for the path confusion is to capitalize the references to the system path, since both posix and windows capitalize it.: "Given a name, mode, and PATH, return the path to the first file which conforms to the given mode found on the PATH, or None if there is no such file. mode defaults to os.F_OK|os.X_OK. PATH can be specified via the path argument, if not specified it defaults to the PATH set in the environment." |
New changeset 5f18d9d34f73 by Brian Curtin in branch 'default': New changeset aa153b827d17 by Brian Curtin in branch 'default': |
Any reason why this is still open? |
Doesn't look like it. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: