Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-78612: Mark up eval() using param list #115212

Merged
merged 5 commits into from
Feb 28, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,17 @@ are always available. They are listed here in alphabetical order.

.. function:: eval(expression, globals=None, locals=None)

The arguments are a string and optional globals and locals. If provided,
*globals* must be a dictionary. If provided, *locals* can be any mapping
object.
:param expression:
Copy link
Member

Choose a reason for hiding this comment

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

This is currently the only function in the page to use :param:. Are you planning to update some/all the others as well?
If not, I think it might be better to keep the original paragraph. Mentioning that it accepts code objects and adding links to that and to "mapping" are good changes.

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 don't think it matters that only one function is marked up better. In any case, there are other good candidates:

  • compile()
  • exec()
  • open()
  • print()
  • __import__()

Possibly also:

  • setattr()
  • sorted()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FTR, I'd suggest adapting one at the time.

A Python expression as a string or a compiled code object.
erlend-aasland marked this conversation as resolved.
Show resolved Hide resolved
:type expression: :class:`str` | :ref:`code object <code-objects>`

:param globals:
The global namespace (default: ``None``).
:type globals: :class:`dict` | ``None``

:param locals:
The local namespace (default: ``None``).
:type locals: :term:`mapping` | ``None``

The *expression* argument is parsed and evaluated as a Python expression
(technically speaking, a condition list) using the *globals* and *locals*
Expand Down