Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 3b9db00

Browse files
author
Anselm Kruis
committed
Merge branch main into main-slp
2 parents 330db40 + 059b9ea commit 3b9db00

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+507
-314
lines changed

‎Doc/faq/programming.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,8 @@ desired effect in a number of ways.
554554
5) Or bundle up values in a class instance::
555555

556556
class callByRef:
557-
def __init__(self, **args):
558-
for (key, value) in args.items():
557+
def __init__(self, /, **args):
558+
for key, value in args.items():
559559
setattr(self, key, value)
560560

561561
def func4(args):

‎Doc/howto/logging-cookbook.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ information. When you call one of the logging methods on an instance of
579579
information in the delegated call. Here's a snippet from the code of
580580
:class:`LoggerAdapter`::
581581

582-
def debug(self, msg, *args, **kwargs):
582+
def debug(self, msg, /, *args, **kwargs):
583583
"""
584584
Delegate a debug call to the underlying logger, after adding
585585
contextual information from this adapter instance.
@@ -1079,7 +1079,7 @@ call ``str()`` on that object to get the actual format string. Consider the
10791079
following two classes::
10801080

10811081
class BraceMessage:
1082-
def __init__(self, fmt, *args, **kwargs):
1082+
def __init__(self, fmt, /, *args, **kwargs):
10831083
self.fmt = fmt
10841084
self.args = args
10851085
self.kwargs = kwargs
@@ -1088,7 +1088,7 @@ following two classes::
10881088
return self.fmt.format(*self.args, **self.kwargs)
10891089

10901090
class DollarMessage:
1091-
def __init__(self, fmt, **kwargs):
1091+
def __init__(self, fmt, /, **kwargs):
10921092
self.fmt = fmt
10931093
self.kwargs = kwargs
10941094

@@ -1143,7 +1143,7 @@ to the above, as in the following example::
11431143

11441144
import logging
11451145

1146-
class Message(object):
1146+
class Message:
11471147
def __init__(self, fmt, args):
11481148
self.fmt = fmt
11491149
self.args = args
@@ -1155,7 +1155,7 @@ to the above, as in the following example::
11551155
def __init__(self, logger, extra=None):
11561156
super(StyleAdapter, self).__init__(logger, extra or {})
11571157

1158-
def log(self, level, msg, *args, **kwargs):
1158+
def log(self, level, msg, /, *args, **kwargs):
11591159
if self.isEnabledFor(level):
11601160
msg, kwargs = self.process(msg, kwargs)
11611161
self.logger._log(level, Message(msg, args), (), **kwargs)
@@ -1301,7 +1301,7 @@ You can also subclass :class:`QueueListener` to get messages from other kinds
13011301
of queues, for example a ZeroMQ 'subscribe' socket. Here's an example::
13021302

13031303
class ZeroMQSocketListener(QueueListener):
1304-
def __init__(self, uri, *handlers, **kwargs):
1304+
def __init__(self, uri, /, *handlers, **kwargs):
13051305
self.ctx = kwargs.get('ctx') or zmq.Context()
13061306
socket = zmq.Socket(self.ctx, zmq.SUB)
13071307
socket.setsockopt_string(zmq.SUBSCRIBE, '') # subscribe to everything
@@ -1706,8 +1706,8 @@ which uses JSON to serialise the event in a machine-parseable manner::
17061706
import json
17071707
import logging
17081708

1709-
class StructuredMessage(object):
1710-
def __init__(self, message, **kwargs):
1709+
class StructuredMessage:
1710+
def __init__(self, message, /, **kwargs):
17111711
self.message = message
17121712
self.kwargs = kwargs
17131713

@@ -1750,8 +1750,8 @@ as in the following complete example::
17501750
return o.encode('unicode_escape').decode('ascii')
17511751
return super(Encoder, self).default(o)
17521752

1753-
class StructuredMessage(object):
1754-
def __init__(self, message, **kwargs):
1753+
class StructuredMessage:
1754+
def __init__(self, message, /, **kwargs):
17551755
self.message = message
17561756
self.kwargs = kwargs
17571757

@@ -1982,17 +1982,17 @@ object as a message format string, and that the logging package will call
19821982
:func:`str` on that object to get the actual format string. Consider the
19831983
following two classes::
19841984

1985-
class BraceMessage(object):
1986-
def __init__(self, fmt, *args, **kwargs):
1985+
class BraceMessage:
1986+
def __init__(self, fmt, /, *args, **kwargs):
19871987
self.fmt = fmt
19881988
self.args = args
19891989
self.kwargs = kwargs
19901990

19911991
def __str__(self):
19921992
return self.fmt.format(*self.args, **self.kwargs)
19931993

1994-
class DollarMessage(object):
1995-
def __init__(self, fmt, **kwargs):
1994+
class DollarMessage:
1995+
def __init__(self, fmt, /, **kwargs):
19961996
self.fmt = fmt
19971997
self.kwargs = kwargs
19981998

@@ -2457,7 +2457,7 @@ scope of the context manager::
24572457
import logging
24582458
import sys
24592459

2460-
class LoggingContext(object):
2460+
class LoggingContext:
24612461
def __init__(self, logger, level=None, handler=None, close=True):
24622462
self.logger = logger
24632463
self.level = level

‎Doc/library/collections.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ variants of :func:`functools.lru_cache`::
11401140
class LRU(OrderedDict):
11411141
'Limit size, evicting the least recently looked-up key when full'
11421142

1143-
def __init__(self, maxsize=128, *args, **kwds):
1143+
def __init__(self, maxsize=128, /, *args, **kwds):
11441144
self.maxsize = maxsize
11451145
super().__init__(*args, **kwds)
11461146

‎Doc/library/contextlib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ even further by means of a small helper class::
637637
from contextlib import ExitStack
638638

639639
class Callback(ExitStack):
640-
def __init__(self, callback, *args, **kwds):
640+
def __init__(self, callback, /, *args, **kwds):
641641
super(Callback, self).__init__()
642642
self.callback(callback, *args, **kwds)
643643

‎Doc/library/email.headerregistry.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ headers.
107107
method if it wishes to set additional attributes beyond those provided by
108108
``BaseHeader`` itself. Such an ``init`` method should look like this::
109109

110-
def init(self, *args, **kw):
110+
def init(self, /, *args, **kw):
111111
self._myattr = kw.pop('myattr')
112112
super().init(*args, **kw)
113113

‎Doc/library/functions.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,8 @@ are always available. They are listed here in alphabetical order.
499499
:func:`exec` function. The return value is ``None``.
500500

501501
In all cases, if the optional parts are omitted, the code is executed in the
502-
current scope. If only *globals* is provided, it must be a dictionary, which
502+
current scope. If only *globals* is provided, it must be a dictionary
503+
(and not a subclass of dictionary), which
503504
will be used for both the global and the local variables. If *globals* and
504505
*locals* are given, they are used for the global and local variables,
505506
respectively. If provided, *locals* can be any mapping object. Remember

‎Doc/library/functools.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ The :mod:`functools` module defines the following functions:
221221
Returning NotImplemented from the underlying comparison function for
222222
unrecognised types is now supported.
223223

224-
.. function:: partial(func, *args, **keywords)
224+
.. function:: partial(func, /, *args, **keywords)
225225

226226
Return a new :ref:`partial object<partial-objects>` which when called
227227
will behave like *func* called with the positional arguments *args*
@@ -230,7 +230,7 @@ The :mod:`functools` module defines the following functions:
230230
supplied, they extend and override *keywords*.
231231
Roughly equivalent to::
232232

233-
def partial(func, *args, **keywords):
233+
def partial(func, /, *args, **keywords):
234234
def newfunc(*fargs, **fkeywords):
235235
newkeywords = {**keywords, **fkeywords}
236236
return func(*args, *fargs, **newkeywords)
@@ -252,7 +252,7 @@ The :mod:`functools` module defines the following functions:
252252
18
253253

254254

255-
.. class:: partialmethod(func, *args, **keywords)
255+
.. class:: partialmethod(func, /, *args, **keywords)
256256

257257
Return a new :class:`partialmethod` descriptor which behaves
258258
like :class:`partial` except that it is designed to be used as a method

‎Doc/library/inspect.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ Classes and functions
10221022
metatype is in use, cls will be the first element of the tuple.
10231023

10241024

1025-
.. function:: getcallargs(func, *args, **kwds)
1025+
.. function:: getcallargs(func, /, *args, **kwds)
10261026

10271027
Bind the *args* and *kwds* to the argument names of the Python function or
10281028
method *func*, as if it was called with them. For bound methods, bind also the

‎Doc/library/math.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,21 @@ Number-theoretic and representation functions
232232
:meth:`x.__trunc__() <object.__trunc__>`.
233233

234234

235+
.. function:: comb(n, k)
236+
237+
Return the number of ways to choose *k* items from *n* items without repetition
238+
and without order.
239+
240+
Also called the binomial coefficient. It is mathematically equal to the expression
241+
``n! / (k! (n - k)!)``. It is equivalent to the coefficient of k-th term in
242+
polynomial expansion of the expression ``(1 + x) ** n``.
243+
244+
Raises :exc:`TypeError` if the arguments not integers.
245+
Raises :exc:`ValueError` if the arguments are negative or if k > n.
246+
247+
.. versionadded:: 3.8
248+
249+
235250
Note that :func:`frexp` and :func:`modf` have a different call/return pattern
236251
than their C equivalents: they take a single argument and return a pair of
237252
values, rather than returning their second return value through an 'output

‎Doc/library/operator.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ expect a function argument.
339339
[('orange', 1), ('banana', 2), ('apple', 3), ('pear', 5)]
340340

341341

342-
.. function:: methodcaller(name[, args...])
342+
.. function:: methodcaller(name, /, *args, **kwargs)
343343

344344
Return a callable object that calls the method *name* on its operand. If
345345
additional arguments and/or keyword arguments are given, they will be given
@@ -352,7 +352,7 @@ expect a function argument.
352352

353353
Equivalent to::
354354

355-
def methodcaller(name, *args, **kwargs):
355+
def methodcaller(name, /, *args, **kwargs):
356356
def caller(obj):
357357
return getattr(obj, name)(*args, **kwargs)
358358
return caller

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /