@@ -378,20 +378,31 @@ The :mod:`functools` module defines the following functions:
378
378
>>> basetwo(' 10010' )
379
379
18
380
380
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
382
382
when :func: `partial ` is called. This allows custom selection of positional arguments
383
383
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:
385
385
386
386
>>> from functools import partial, Placeholder
387
- >>> say_to_world = partial(print , Placeholder, ' world!' )
387
+ >>> say_to_world = partial(print , Placeholder, Placeholder, " world!" )
388
388
>>> 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 `.
392
394
393
395
.. 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
395
406
396
407
.. class :: partialmethod(func, /, *args, **keywords)
397
408
0 commit comments