[Python-ideas] Keyword-only arguments?

Ethan Furman ethan at stoneleaf.us
Wed Jun 17 21:25:22 CEST 2015


On 06/17/2015 12:11 PM, Amber Yust wrote:
>
> Interesting. I don't think I've ever seen it used, even having looked at Python 3 code. For those who have worked with more Python 3 code than I have, do you ever see it used?

We don't typically go back and modify existing code to use new features, so your best bet to see it used is to find new features in Python 3.

Or, do a grep on the source code:

base64.py:def a85encode(b, *, foldspaces=False, wrapcol=0, pad=False, adobe=False):
base64.py:def a85decode(b, *, foldspaces=False, adobe=False, ignorechars=b' \t\n\r\v'):
codecs.py:        *, _is_text_encoding=None):
configparser.py:                 allow_no_value=False, *, delimiters=('=', ':'),
configparser.py:    def get(self, section, option, *, raw=False, vars=None, fallback=_UNSET):
configparser.py:    def _get_conv(self, section, option, conv, *, raw=False, vars=None,
configparser.py:    def getint(self, section, option, *, raw=False, vars=None,
configparser.py:    def getfloat(self, section, option, *, raw=False, vars=None,
configparser.py:    def getboolean(self, section, option, *, raw=False, vars=None,
configparser.py:    def _validate_value_types(self, *, section="", option="", value=""):
configparser.py:    def get(self, option, fallback=None, *, raw=False, vars=None,
datetime.py:# standard time.  Since that's what the local clock *does*, we want to map both
difflib.py:                  context=False, numlines=5, *, charset='utf-8'):
dis.py:def dis(x=None, *, file=None):
dis.py:def distb(tb=None, *, file=None):
dis.py:def show_code(co, *, file=None):
dis.py:def get_instructions(x, *, first_line=None):
dis.py:def disassemble(co, lasti=-1, *, file=None):
dis.py:                       *, file=None, line_offset=0):
dis.py:def _disassemble_str(source, *, file=None):
dis.py:    def __init__(self, x, *, first_line=None, current_offset=None):
enum.py:    def __call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1):
enum.py:    def _create_(cls, class_name, names=None, *, module=None, qualname=None, type=None, start=1):
functools.py:            # an ABC *base*, insert said ABC to its MRO.
glob.py:def glob(pathname, *, recursive=False):
glob.py:def iglob(pathname, *, recursive=False):
inspect.py:attributes (co_*, im_*, tb_*, etc.) in a friendlier fashion.
inspect.py:def unwrap(func, *, stop=None):
inspect.py:                    # signature: "(*, a='spam', b, c)". Because attempting
inspect.py:def _signature_from_callable(obj, *,
inspect.py:    def __init__(self, name, kind, *, default=_empty, annotation=_empty):
inspect.py:    def replace(self, *, name=_void, kind=_void,
inspect.py:    def __init__(self, parameters=None, *, return_annotation=_empty,
inspect.py:    def from_callable(cls, obj, *, follow_wrapped=True):
inspect.py:    def replace(self, *, parameters=_void, return_annotation=_void):
inspect.py:    def _bind(self, args, kwargs, *, partial=False):
inspect.py:                # separator to the parameters list ("foo(arg1, *, arg2)" case)
inspect.py:def signature(obj, *, follow_wrapped=True):
lzma.py:    def __init__(self, filename=None, mode="r", *,
lzma.py:def open(filename, mode="rb", *,
lzma.py:    optional arguments *format*, *check*, *preset* and *filters*.
lzma.py:    optional arguments *format*, *check* and *filters*.
nntplib.py:    def newgroups(self, date, *, file=None):
nntplib.py:    def newnews(self, group, date, *, file=None):
nntplib.py:    def list(self, group_pattern=None, *, file=None):
nntplib.py:    def help(self, *, file=None):
nntplib.py:    def head(self, message_spec=None, *, file=None):
nntplib.py:    def body(self, message_spec=None, *, file=None):
nntplib.py:    def article(self, message_spec=None, *, file=None):
nntplib.py:    def xhdr(self, hdr, str, *, file=None):
nntplib.py:    def xover(self, start, end, *, file=None):
nntplib.py:    def over(self, message_spec, *, file=None):
nntplib.py:    def xgtitle(self, group, *, file=None):
ntpath.py:# See also module 'glob' for expansion of *, ? and [...] in pathnames.
numbers.py:    *, /, abs(), .conjugate, ==, and !=.
os.py:    def fwalk(top=".", topdown=True, onerror=None, *, follow_symlinks=False, dir_fd=None):
pickle.py:    def __init__(self, file, protocol=None, *, fix_imports=True):
pickle.py:    def __init__(self, file, *, fix_imports=True,
pickle.py:        Optional keyword arguments are *fix_imports*, *encoding* and
pickle.py:        *errors*, which are used to control compatiblity support for
pickle.py:def _dump(obj, file, protocol=None, *, fix_imports=True):
pickle.py:def _dumps(obj, protocol=None, *, fix_imports=True):
pickle.py:def _load(file, *, fix_imports=True, encoding="ASCII", errors="strict"):
pickle.py:def _loads(s, *, fix_imports=True, encoding="ASCII", errors="strict"):
plistlib.py:def load(fp, *, fmt=None, use_builtin_types=True, dict_type=dict):
plistlib.py:def loads(value, *, fmt=None, use_builtin_types=True, dict_type=dict):
plistlib.py:def dump(value, fp, *, fmt=FMT_XML, sort_keys=True, skipkeys=False):
plistlib.py:def dumps(value, *, fmt=FMT_XML, skipkeys=False, sort_keys=True):
posixpath.py:# See also module 'glob' for expansion of *, ? and [...] in pathnames.
pprint.py:def pprint(object, stream=None, indent=1, width=80, depth=None, *,
pprint.py:def pformat(object, indent=1, width=80, depth=None, *, compact=False):
pprint.py:    def __init__(self, indent=1, width=80, depth=None, stream=None, *,
pydoc.py:def browse(port=0, *, open_browser=True):
_pyio.py:    *opener* with (*file*, *flags*). *opener* must return an open file
_pyio.py:        """Read up to len(b) bytes into *b*, using at most one system call
_pyio.py:        object is then obtained by calling opener with (*name*, *flags*).
shutil.py:def copyfile(src, dst, *, follow_symlinks=True):
shutil.py:def copymode(src, dst, *, follow_symlinks=True):
shutil.py:    def _copyxattr(src, dst, *, follow_symlinks=True):
shutil.py:def copystat(src, dst, *, follow_symlinks=True):
shutil.py:def copy(src, dst, *, follow_symlinks=True):
shutil.py:def copy2(src, dst, *, follow_symlinks=True):
socket.py:    def makefile(self, mode="r", buffering=None, *,
ssl.py:def create_default_context(purpose=Purpose.SERVER_AUTH, *, cafile=None,
ssl.py:def _create_unverified_context(protocol=PROTOCOL_SSLv23, *, cert_reqs=None,
tarfile.py:    def list(self, verbose=True, *, members=None):
tarfile.py:    def add(self, name, arcname=None, recursive=True, exclude=None, *, filter=None):
tarfile.py:    def extractall(self, path=".", members=None, *, numeric_owner=False):
tarfile.py:    def extract(self, member, path="", set_attrs=True, *, numeric_owner=False):
textwrap.py:                 *,
textwrap.py:    the *width*, it is returned as is.  Otherwise, as many words
threading.py:                 args=(), kwargs=None, *, daemon=None):
timeit.py:def main(args=None, *, _wrap_timer=None):
traceback.py:    def __init__(self, filename, lineno, name, *, lookup_line=True,
traceback.py:    def extract(klass, frame_gen, *, limit=None, lookup_lines=True,
traceback.py:    def __init__(self, exc_type, exc_value, exc_traceback, *, limit=None,
traceback.py:    def format(self, *, chain=True):
traceback.py:        If chain is not *True*, *__cause__* and *__context__* will not be formatted.
typing.py:    def __new__(cls, name, bases, namespace, *, _root=False):
warnings.py:    def __init__(self, *, record=False, module=None):

--
~Ethan~


More information about the Python-ideas mailing list