Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/docsite/rst/dev_guide/developing_python_3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,13 @@ does have support for the older, percent-formatting.

b_command_line = b'ansible-playbook --become-user %s -K %s' % (user, playbook_file)

Use f-strings for Python 3.6+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

In Python 3.6 and later, f-strings (formatted string literals) are a more readable and concise way to format strings.

.. code-block:: python

b_command_line = f"ansible-playbook --become-user {user} -K {playbook_file}"
Comment on lines 380 to +389
Copy link
Member

Choose a reason for hiding this comment

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

I'm not happy with these examples show constructing commands through string concatenation. This is a straight way to command injection. These must use shlex.quote() / shlex.join().

It'd be better to use something else in examples.


.. _testing_modules_python_3: