@@ -354,7 +354,7 @@ The :mod:`functools` module defines the following functions:
354
354
newfunc.keywords = keywords
355
355
return newfunc
356
356
357
- The :func: `partial ` function is used for partial function application which "freezes"
357
+ The :func: `! partial ` function is used for partial function application which "freezes"
358
358
some portion of a function's arguments and/or keywords resulting in a new object
359
359
with a simplified signature. For example, :func: `partial ` can be used to create
360
360
a callable that behaves like the :func: `int ` function where the *base * argument
@@ -368,25 +368,27 @@ The :mod:`functools` module defines the following functions:
368
368
18
369
369
370
370
If :data: `Placeholder ` sentinels are present in *args *, they will be filled first
371
- when :func: `partial ` is called. This allows custom selection of positional arguments
372
- to be pre-filled when constructing a :ref: `partial object <partial-objects >`.
371
+ when :func: `!partial ` is called. This makes it possible to pre-fill any positional
372
+ argument with a call to :func: `!partial `; without :data: `!Placeholder `, only the
373
+ first positional argument can be pre-filled.
373
374
374
- If :data: `!Placeholder ` sentinels are present, all of them must be filled at call time:
375
+ If any :data: `!Placeholder ` sentinels are present, all must be filled at call time:
375
376
376
377
.. doctest ::
377
378
378
379
>>> say_to_world = partial(print , Placeholder, Placeholder, " world!" )
379
380
>>> say_to_world(' Hello' , ' dear' )
380
381
Hello dear world!
381
382
382
- Calling ``say_to_world('Hello') `` would raise a :exc: `TypeError `, because
383
- only one positional argument is provided, while there are two placeholders
384
- in :ref: ` partial object < partial-objects >` .
383
+ Calling ``say_to_world('Hello') `` raises a :exc: `TypeError `, because
384
+ only one positional argument is provided, but there are two placeholders
385
+ that must be filled in .
385
386
386
- Successive :func: `partial ` applications fill :data: `!Placeholder ` sentinels
387
- of the input :func: `partial ` objects with new positional arguments.
388
- A place for positional argument can be retained by inserting new
389
- :data: `!Placeholder ` sentinel to the place held by previous :data: `!Placeholder `:
387
+ If :func: `!partial ` is applied to an existing :func: `!partial ` object,
388
+ :data: `!Placeholder ` sentinels of the input object are filled in with
389
+ new positional arguments.
390
+ A placeholder can be retained by inserting a new
391
+ :data: `!Placeholder ` sentinel to the place held by a previous :data: `!Placeholder `:
390
392
391
393
.. doctest ::
392
394
@@ -402,8 +404,8 @@ The :mod:`functools` module defines the following functions:
402
404
>>> remove_first_dear(message)
403
405
'Hello, dear world!'
404
406
405
- Note, :data: `!Placeholder ` has no special treatment when used for keyword
406
- argument of :data : `!Placeholder `.
407
+ :data: `!Placeholder ` has no special treatment when used in a keyword
408
+ argument to :func : `!partial `.
407
409
408
410
.. versionchanged :: 3.14
409
411
Added support for :data: `Placeholder ` in positional arguments.
@@ -791,7 +793,7 @@ have three read-only attributes:
791
793
The keyword arguments that will be supplied when the :class: `partial ` object is
792
794
called.
793
795
794
- :class: `partial ` objects are like :class : `function ` objects in that they are
796
+ :class: `partial ` objects are like :ref : `function objects < user-defined-funcs >` in that they are
795
797
callable, weak referenceable, and can have attributes. There are some important
796
- differences. For instance, the :attr: `~definition.__name__ ` and :attr: `__doc__ ` attributes
798
+ differences. For instance, the :attr: `~definition.__name__ ` and :attr: `~definition. __doc__ ` attributes
797
799
are not created automatically.
0 commit comments