@@ -236,20 +236,24 @@ Create an ignored variable
236
236
~~~~~~~~~~~~~~~~~~~~~~~~~~
237
237
238
238
If you need to assign something (for instance, in :ref:`unpacking- ref` ) but
239
- will not need that variable, use `` _ `` :
239
+ will not need that variable, use `` __ `` :
240
240
241
241
.. code- block:: python
242
242
243
243
filename = ' foobar.txt'
244
- basename, _ , ext = filename.rpartition()
244
+ basename, __ , ext = filename.rpartition()
245
245
246
246
.. note::
247
247
248
- " ``_``" is commonly used as an alias for the :func:`~ gettext.gettext`
249
- function. If your application uses (or may someday use) :mod:`gettext` ,
250
- you may want to avoid using `` _`` for ignored variables, as you may
251
- accidentally shadow :func:`~ gettext.gettext` .
252
-
248
+ Many Python style guides recommend the use of a single underscore " ``_``"
249
+ for throwaway variables rather than the double underscore " ``__``"
250
+ recommended here. The issue is that " ``_``" is commonly used as an alias
251
+ for the :func:`~ gettext.gettext` function, and is also used at the
252
+ interactive prompt to hold the value of the last operation. Using a
253
+ double underscore instead is just as clear and almost as convenient,
254
+ and eliminates the risk of accidentally interfering with either of
255
+ these other use cases.
256
+
253
257
Create a length- N list of the same thing
254
258
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
255
259
0 commit comments