Skip to content

Commit caec6e8

Browse files
committed
documentation update
1 parent 6fea348 commit caec6e8

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

Doc/library/functools.rst

+18-7
Original file line numberDiff line numberDiff line change
@@ -378,20 +378,31 @@ The :mod:`functools` module defines the following functions:
378378
>>> basetwo('10010')
379379
18
380380

381-
If ``Placeholder`` sentinels are present in *args*, they will be filled first
381+
If :data:`Placeholder` sentinels are present in *args*, they will be filled first
382382
when :func:`partial` is called. This allows custom selection of positional arguments
383383
to be pre-filled when constructing :ref:`partial object<partial-objects>`.
384-
If ``Placeholder`` sentinels are used, all of them must be filled at call time:
384+
If :data:`Placeholder` sentinels are used, all of them must be filled at call time:
385385

386386
>>> from functools import partial, Placeholder
387-
>>> say_to_world = partial(print, Placeholder, 'world!')
387+
>>> say_to_world = partial(print, Placeholder, Placeholder, "world!")
388388
>>> say_to_world.placeholder_count
389-
1
390-
>>> say_to_world('Hello')
391-
Hello world!
389+
2
390+
>>> say_to_world('Hello', 'dear')
391+
Hello dear world!
392+
393+
Calling ``say_to_world('Hello')`` would result in :exc:`TypeError`.
392394

393395
.. versionchanged:: 3.14
394-
Support for ``Placeholder`` in *args*
396+
Support for :data:`Placeholder` in *args*
397+
398+
.. data:: Placeholder
399+
400+
This is a singleton object that is used as a sentinel for representing a
401+
gap in positional arguments when calling :func:`partial`.
402+
It has similar features as :data:`None`:
403+
404+
>>> type(Placeholder)() is Placeholder
405+
True
395406

396407
.. class:: partialmethod(func, /, *args, **keywords)
397408

0 commit comments

Comments
 (0)