Discussion: https://discuss.python.org/t/slight-grammar-fix-throughout-adverbs-dont-need-hyphen/17021
.. c:function:: PyObject* PyObject_Init(PyObject *op, PyTypeObject *type)
- Initialize a newly-allocated object *op* with its type and initial
+ Initialize a newly allocated object *op* with its type and initial
reference. Returns the initialized object. If *type* indicates that the
object participates in the cyclic garbage detector, it is added to the
detector's set of observed objects. Other fields of the object are not
:file:`Misc/SpecialBuilds.txt` in the Python source distribution. Builds are
available that support tracing of reference counts, debugging the memory
allocator, or low-level profiling of the main interpreter loop. Only the most
-frequently-used builds will be described in the remainder of this section.
+frequently used builds will be described in the remainder of this section.
Compiling the interpreter with the :c:macro:`Py_DEBUG` macro defined produces
what is generally meant by :ref:`a debug build of Python <debug-build>`.
with new object types written in C. Another reason for using the Python heap is
the desire to *inform* the Python memory manager about the memory needs of the
extension module. Even when the requested memory is used exclusively for
-internal, highly-specific purposes, delegating all memory requests to the Python
+internal, highly specific purposes, delegating all memory requests to the Python
memory manager causes the interpreter to have a more accurate image of its
memory footprint as a whole. Consequently, under certain circumstances, the
Python memory manager may or may not trigger appropriate actions, like garbage
``PyObject_HEAD_INIT`` macro. For :ref:`statically allocated objects
<static-types>`, these fields always remain ``NULL``. For :ref:`dynamically
allocated objects <heap-types>`, these two fields are used to link the
- object into a doubly-linked list of *all* live objects on the heap.
+ object into a doubly linked list of *all* live objects on the heap.
This could be used for various debugging purposes; currently the only uses
are the :func:`sys.getobjects` function and to print the objects that are
callable object that receives notification when *ob* is garbage collected; it
should accept a single parameter, which will be the weak reference object
itself. *callback* may also be ``None`` or ``NULL``. If *ob* is not a
- weakly-referencable object, or if *callback* is not callable, ``None``, or
+ weakly referencable object, or if *callback* is not callable, ``None``, or
``NULL``, this will return ``NULL`` and raise :exc:`TypeError`.
be a callable object that receives notification when *ob* is garbage
collected; it should accept a single parameter, which will be the weak
reference object itself. *callback* may also be ``None`` or ``NULL``. If *ob*
- is not a weakly-referencable object, or if *callback* is not callable,
+ is not a weakly referencable object, or if *callback* is not callable,
``None``, or ``NULL``, this will return ``NULL`` and raise :exc:`TypeError`.
it contains certain values: see :func:`check_environ`. Raise :exc:`ValueError`
for any variables not found in either *local_vars* or ``os.environ``.
- Note that this is not a fully-fledged string interpolation function. A valid
+ Note that this is not a full-fledged string interpolation function. A valid
``$variable`` can consist only of upper and lower case letters, numbers and an
underscore. No { } or ( ) style quoting is available.
.. c:function:: PyObject* PyInit_modulename(void)
-It returns either a fully-initialized module, or a :c:type:`PyModuleDef`
+It returns either a fully initialized module, or a :c:type:`PyModuleDef`
instance. See :ref:`initializing-modules` for details.
.. highlight:: python
}
If no :c:member:`~PyTypeObject.tp_repr` handler is specified, the interpreter will supply a
-representation that uses the type's :c:member:`~PyTypeObject.tp_name` and a uniquely-identifying
+representation that uses the type's :c:member:`~PyTypeObject.tp_name` and a uniquely identifying
value for the object.
The :c:member:`~PyTypeObject.tp_str` handler is to :func:`str` what the :c:member:`~PyTypeObject.tp_repr` handler
PyObject *weakreflist; /* List of weak references */
} TrivialObject;
-And the corresponding member in the statically-declared type object::
+And the corresponding member in the statically declared type object::
static PyTypeObject TrivialType = {
PyVarObject_HEAD_INIT(NULL, 0)
Functions are already first class objects in Python, and can be declared in a
local scope. Therefore the only advantage of using a lambda instead of a
-locally-defined function is that you don't need to invent a name for the
+locally defined function is that you don't need to invent a name for the
function -- but that's just a local variable to which the function object (which
is exactly the same type of object that a lambda expression yields) is assigned!
1. standard library modules -- e.g. ``sys``, ``os``, ``getopt``, ``re``
2. third-party library modules (anything installed in Python's site-packages
directory) -- e.g. mx.DateTime, ZODB, PIL.Image, etc.
-3. locally-developed modules
+3. locally developed modules
It is sometimes necessary to move imports to a function or class to avoid
problems with circular imports. Gordon McMillan says:
A slash in the argument list of a function denotes that the parameters prior to
it are positional-only. Positional-only parameters are the ones without an
-externally-usable name. Upon calling a function that accepts positional-only
+externally usable name. Upon calling a function that accepts positional-only
parameters, arguments are mapped to parameters based solely on their position.
For example, :func:`divmod` is a function that accepts positional-only
parameters. Its documentation looks like this::
machines.
However, some extension modules, either standard or third-party,
- are designed so as to release the GIL when doing computationally-intensive
+ are designed so as to release the GIL when doing computationally intensive
tasks such as compression or hashing. Also, the GIL is always released
when doing I/O.
16. Compile, then run the relevant portions of the regression-test suite.
This change should not introduce any new compile-time warnings or errors,
- and there should be no externally-visible change to Python's behavior.
+ and there should be no externally visible change to Python's behavior.
Well, except for one difference: ``inspect.signature()`` run on your function
should now provide a valid signature!
``module.class`` in the sample just to illustrate that you must
use the full path to *both* functions.)
-Sorry, there's no syntax for partially-cloning a function, or cloning a function
+Sorry, there's no syntax for partially cloning a function, or cloning a function
then modifying it. Cloning is an all-or nothing proposition.
Also, the function you are cloning from must have been previously defined
there is no default, but not specifying a default may
result in an "uninitialized variable" warning. This can
easily happen when using option groups—although
- properly-written code will never actually use this value,
+ properly written code will never actually use this value,
the variable does get passed in to the impl, and the
C compiler will complain about the "use" of the
uninitialized value. This value should always be a
The itertools module
====================
-The :mod:`itertools` module contains a number of commonly-used iterators as well
+The :mod:`itertools` module contains a number of commonly used iterators as well
as functions for combining several iterators. This section will introduce the
module's contents by showing small examples.
Arguments: 8@%rbp 8@%r12 -4@%eax
The above metadata contains information for SystemTap describing how it
-can patch strategically-placed machine code instructions to enable the
+can patch strategically placed machine code instructions to enable the
tracing hooks used by a SystemTap script.
The following script uses the tapset above to provide a top-like view of all
-running CPython code, showing the top 20 most frequently-entered bytecode
+running CPython code, showing the top 20 most frequently entered bytecode
frames, each second, across the whole system:
.. code-block:: none
^^^^^^^^^^^^^^^^^
A very common situation is that of recording logging events in a file, so let's
-look at that next. Be sure to try the following in a newly-started Python
+look at that next. Be sure to try the following in a newly started Python
interpreter, and don't just continue from the session described above::
import logging
>>> m.groupdict()
{'first': 'Jane', 'last': 'Doe'}
-Named groups are handy because they let you use easily-remembered names, instead
+Named groups are handy because they let you use easily remembered names, instead
of having to remember numbers. Here's an example RE from the :mod:`imaplib`
module::
====================
When you fetch a URL you use an opener (an instance of the perhaps
-confusingly-named :class:`urllib.request.OpenerDirector`). Normally we have been using
+confusingly named :class:`urllib.request.OpenerDirector`). Normally we have been using
the default opener - via ``urlopen`` - but you can create custom
openers. Openers use handlers. All the "heavy lifting" is done by the
handlers. Each handler knows how to open URLs for a particular URL scheme (http,
was packaged and distributed in the standard way, i.e. using the Distutils.
First, the distribution's name and version number will be featured prominently
in the name of the downloaded archive, e.g. :file:`foo-1.0.tar.gz` or
-:file:`widget-0.9.7.zip`. Next, the archive will unpack into a similarly-named
+:file:`widget-0.9.7.zip`. Next, the archive will unpack into a similarly named
directory: :file:`foo-1.0` or :file:`widget-0.9.7`. Additionally, the
distribution will contain a setup script :file:`setup.py`, and a file named
:file:`README.txt` or possibly just :file:`README`, which should explain that
.. method:: async_chat.push_with_producer(producer)
Takes a producer object and adds it to the producer queue associated with
- the channel. When all currently-pushed producers have been exhausted the
+ the channel. When all currently pushed producers have been exhausted the
channel will consume this producer's data by calling its :meth:`more`
method and send the data to the remote endpoint.
Python's interactive interpreter. If you want a Python interpreter that
supports some special feature in addition to the Python language, you should
look at the :mod:`code` module. (The :mod:`codeop` module is lower-level, used
-to support compiling a possibly-incomplete chunk of Python code.)
+to support compiling a possibly incomplete chunk of Python code.)
The full list of modules described in this chapter is:
--------------
-The :mod:`decimal` module provides support for fast correctly-rounded
+The :mod:`decimal` module provides support for fast correctly rounded
decimal floating point arithmetic. It offers several advantages over the
:class:`float` datatype:
With two arguments, compute ``x**y``. If ``x`` is negative then ``y``
must be integral. The result will be inexact unless ``y`` is integral and
the result is finite and can be expressed exactly in 'precision' digits.
- The rounding mode of the context is used. Results are always correctly-rounded
+ The rounding mode of the context is used. Results are always correctly rounded
in the Python version.
``Decimal(0) ** Decimal(0)`` results in ``InvalidOperation``, and if ``InvalidOperation``
is not trapped, then results in ``Decimal('NaN')``.
.. versionchanged:: 3.3
- The C module computes :meth:`power` in terms of the correctly-rounded
+ The C module computes :meth:`power` in terms of the correctly rounded
:meth:`exp` and :meth:`ln` functions. The result is well-defined but
- only "almost always correctly-rounded".
+ only "almost always correctly rounded".
With three arguments, compute ``(x**y) % modulo``. For the three argument
form, the following restrictions on the arguments hold:
A. Yes. In the CPython and PyPy3 implementations, the C/CFFI versions of
the decimal module integrate the high speed `libmpdec
<https://www.bytereef.org/mpdecimal/doc/libmpdec/index.html>`_ library for
-arbitrary precision correctly-rounded decimal floating point arithmetic [#]_.
+arbitrary precision correctly rounded decimal floating point arithmetic [#]_.
``libmpdec`` uses `Karatsuba multiplication
<https://en.wikipedia.org/wiki/Karatsuba_algorithm>`_
for medium-sized numbers and the `Number Theoretic Transform
When specified, doctests expecting exceptions pass so long as an exception
of the expected type is raised, even if the details
- (message and fully-qualified exception name) don't match.
+ (message and fully qualified exception name) don't match.
For example, an example expecting ``ValueError: 42`` will pass if the actual
exception raised is ``ValueError: 3*14``, but will fail if, say, a
:exc:`TypeError` is raised instead.
- It will also ignore any fully-qualified name included before the
+ It will also ignore any fully qualified name included before the
exception class, which can vary between implementations and versions
of Python and the code/libraries in use.
Hence, all three of these variations will work with the flag specified:
.. function:: glob(pathname, *, root_dir=None, dir_fd=None, recursive=False, \
include_hidden=False)
- Return a possibly-empty list of path names that match *pathname*, which must be
+ Return a possibly empty list of path names that match *pathname*, which must be
a string containing a path specification. *pathname* can be either absolute
(like :file:`/usr/src/Python-1.5/Makefile`) or relative (like
:file:`../../Tools/\*/\*.gif`), and can contain shell-style wildcards. Broken
.. warning::
- When comparing the output of :meth:`digest` to an externally-supplied
+ When comparing the output of :meth:`digest` to an externally supplied
digest during a verification routine, it is recommended to use the
:func:`compare_digest` function instead of the ``==`` operator
to reduce the vulnerability to timing attacks.
.. warning::
- When comparing the output of :meth:`hexdigest` to an externally-supplied
+ When comparing the output of :meth:`hexdigest` to an externally supplied
digest during a verification routine, it is recommended to use the
:func:`compare_digest` function instead of the ``==`` operator
to reduce the vulnerability to timing attacks.
reloaded):
- :attr:`__name__`
- The module's fully-qualified name.
+ The module's fully qualified name.
It is ``'__main__'`` for an executed module.
- :attr:`__file__`
as an indicator that the module is a package.
- :attr:`__package__`
- The fully-qualified name of the package the module is in (or the
+ The fully qualified name of the package the module is in (or the
empty string for a top-level module).
If the module is a package then this is the same as :attr:`__name__`.
(:attr:`__name__`)
- The module's fully-qualified name.
+ The module's fully qualified name.
The :term:`finder` should always set this attribute to a non-empty string.
.. attribute:: loader
(:attr:`__package__`)
- (Read-only) The fully-qualified name of the package the module is in (or the
+ (Read-only) The fully qualified name of the package the module is in (or the
empty string for a top-level module).
If the module is a package then this is the same as :attr:`name`.
| | co_name | name with which this code |
| | | object was defined |
+-----------+-------------------+---------------------------+
-| | co_qualname | fully-qualified name with |
+| | co_qualname | fully qualified name with |
| | | which this code object |
| | | was defined |
+-----------+-------------------+---------------------------+
doesn't have its own annotations dict, returns an empty dict.
* All accesses to object members and dict values are done
using ``getattr()`` and ``dict.get()`` for safety.
- * Always, always, always returns a freshly-created dict.
+ * Always, always, always returns a freshly created dict.
``eval_str`` controls whether or not values of type ``str`` are replaced
with the result of calling :func:`eval()` on those values:
Raised when some mailbox-related condition beyond the control of the program
causes it to be unable to proceed, such as when failing to acquire a lock that
- another program already holds a lock, or when a uniquely-generated file name
+ another program already holds a lock, or when a uniquely generated file name
already exists.
line-wrapping---\ :mod:`optparse` takes care of wrapping lines and making
the help output look good.
-* options that take a value indicate this fact in their automatically-generated
+* options that take a value indicate this fact in their automatically generated
help message, e.g. for the "mode" option::
-m MODE, --mode=MODE
:mod:`optparse` converts the destination variable name to uppercase and uses
that for the meta-variable. Sometimes, that's not what you want---for
example, the ``--filename`` option explicitly sets ``metavar="FILE"``,
- resulting in this automatically-generated option description::
+ resulting in this automatically generated option description::
-f FILE, --filename=FILE
parser.add_option("-n", "--dry-run", ..., help="do no harm")
parser.add_option("-n", "--noisy", ..., help="be noisy")
-At this point, :mod:`optparse` detects that a previously-added option is already
+At this point, :mod:`optparse` detects that a previously added option is already
using the ``-n`` option string. Since ``conflict_handler`` is ``"resolve"``,
it resolves the situation by removing ``-n`` from the earlier option's list of
option strings. Now ``--dry-run`` is the only way for the user to activate
...
-n, --noisy be noisy
-It's possible to whittle away the option strings for a previously-added option
+It's possible to whittle away the option strings for a previously added option
until there are none left, and the user has no way of invoking that option from
the command-line. In that case, :mod:`optparse` removes that option completely,
so it doesn't show up in help text or anywhere else. Carrying on with our
The *mode* parameter is passed to :func:`mkdir` for creating the leaf
directory; see :ref:`the mkdir() description <mkdir_modebits>` for how it
- is interpreted. To set the file permission bits of any newly-created parent
+ is interpreted. To set the file permission bits of any newly created parent
directories you can set the umask before invoking :func:`makedirs`. The
file permission bits of existing parent directories are not changed.
.. versionchanged:: 3.7
The *mode* argument no longer affects the file permission bits of
- newly-created intermediate-level directories.
+ newly created intermediate-level directories.
.. function:: mkfifo(path, mode=0o666, *, dir_fd=None)
.. function:: choice(sequence)
- Return a randomly-chosen element from a non-empty sequence.
+ Return a randomly chosen element from a non-empty sequence.
.. function:: randbelow(n)
Applications should not
`store passwords in a recoverable format <http://cwe.mitre.org/data/definitions/257.html>`_,
whether plain text or encrypted. They should be salted and hashed
- using a cryptographically-strong one-way (irreversible) hash function.
+ using a cryptographically strong one-way (irreversible) hash function.
Generate a ten-character alphanumeric password with at least one
.. method:: devpoll.poll([timeout])
- Polls the set of registered file descriptors, and returns a possibly-empty list
+ Polls the set of registered file descriptors, and returns a possibly empty list
containing ``(fd, event)`` 2-tuples for the descriptors that have events or
errors to report. *fd* is the file descriptor, and *event* is a bitmask with
bits set for the reported events for that descriptor --- :const:`POLLIN` for
.. method:: poll.poll([timeout])
- Polls the set of registered file descriptors, and returns a possibly-empty list
+ Polls the set of registered file descriptors, and returns a possibly empty list
containing ``(fd, event)`` 2-tuples for the descriptors that have events or
errors to report. *fd* is the file descriptor, and *event* is a bitmask with
bits set for the reported events for that descriptor --- :const:`POLLIN` for
When *follow_symlinks* is false, and *src* is a symbolic
link, :func:`copy2` attempts to copy all metadata from the
- *src* symbolic link to the newly-created *dst* symbolic link.
+ *src* symbolic link to the newly created *dst* symbolic link.
However, this functionality is not available on all platforms.
On platforms where some or all of this functionality is
unavailable, :func:`copy2` will preserve all the metadata
.. attribute:: fqdn
- Holds the fully-qualified domain name of the server as returned by
+ Holds the fully qualified domain name of the server as returned by
:func:`socket.getfqdn`.
.. attribute:: peer
- A string or a tuple ``(id, unit)`` is used for the :const:`SYSPROTO_CONTROL`
protocol of the :const:`PF_SYSTEM` family. The string is the name of a
- kernel control using a dynamically-assigned ID. The tuple can be used if ID
+ kernel control using a dynamically assigned ID. The tuple can be used if ID
and unit number of the kernel control are known or if a registered ID is
used.
.. function:: getnameinfo(sockaddr, flags)
Translate a socket address *sockaddr* into a 2-tuple ``(host, port)``. Depending
- on the settings of *flags*, the result can contain a fully-qualified domain name
+ on the settings of *flags*, the result can contain a fully qualified domain name
or numeric address representation in *host*. Similarly, *port* can contain a
string port name or a numeric port number.
If returning a tuple doesn't suffice and you want name-based access to
columns, you should consider setting :attr:`row_factory` to the
- highly-optimized :class:`sqlite3.Row` type. :class:`Row` provides both
+ highly optimized :class:`sqlite3.Row` type. :class:`Row` provides both
index-based and case-insensitive name-based access to columns with almost no
memory overhead. It will probably be better than your own custom
dictionary-based approach or even a db_row based solution.
Iteratively unpack from the buffer *buffer* according to the format
string *format*. This function returns an iterator which will read
- equally-sized chunks from the buffer until all its contents have been
+ equally sized chunks from the buffer until all its contents have been
consumed. The buffer's size in bytes must be a multiple of the size
required by the format, as reflected by :func:`calcsize`.
.. warning::
- For maximum reliability, use a fully-qualified path for the executable.
+ For maximum reliability, use a fully qualified path for the executable.
To search for an unqualified name on :envvar:`PATH`, use
:meth:`shutil.which`. On all platforms, passing :data:`sys.executable`
is the recommended way to launch the current Python interpreter again,
internally when it is safe to do so rather than ``fork()``. This greatly
improves performance.
-If you ever encounter a presumed highly-unusual situation where you need to
+If you ever encounter a presumed highly unusual situation where you need to
prevent ``vfork()`` from being used by Python, you can set the
:attr:`subprocess._USE_VFORK` attribute to a false value.
files and stores pathnames in a portable way. Modern tar implementations,
including GNU tar, bsdtar/libarchive and star, fully support extended *pax*
features; some old or unmaintained libraries may not, but should treat
- *pax* archives as if they were in the universally-supported *ustar* format.
+ *pax* archives as if they were in the universally supported *ustar* format.
It is the current default format for new archives.
It extends the existing *ustar* format with extra headers for information
Modify or inquire widget state. If *statespec* is specified, sets the
widget state according to it and return a new *statespec* indicating
which flags were changed. If *statespec* is not specified, returns
- the currently-enabled state flags.
+ the currently enabled state flags.
*statespec* will usually be a list or a tuple.
Ttk Notebook widget manages a collection of windows and displays a single
one at a time. Each child window is associated with a tab, which the user
-may select to change the currently-displayed window.
+may select to change the currently displayed window.
Options
* An integer between zero and the number of tabs
* The name of a child window
* A positional specification of the form "@x,y", which identifies the tab
-* The literal string "current", which identifies the currently-selected tab
+* The literal string "current", which identifies the currently selected tab
* The literal string "end", which returns the number of tabs (only valid for
:meth:`Notebook.index`)
Selects the specified *tab_id*.
The associated child window will be displayed, and the
- previously-selected window (if different) is unmapped. If *tab_id* is
+ previously selected window (if different) is unmapped. If *tab_id* is
omitted, returns the widget name of the currently selected pane.
*Introducing* :data:`TypeVarTuple`
* :pep:`647`: User-Defined Type Guards
*Introducing* :data:`TypeGuard`
-* :pep:`655`: Marking individual TypedDict items as required or potentially-missing
+* :pep:`655`: Marking individual TypedDict items as required or potentially missing
*Introducing* :data:`Required` and :data:`NotRequired`
* :pep:`673`: Self type
*Introducing* :data:`Self`
as either required or non-required respectively.
For more information, see :class:`TypedDict` and
- :pep:`655` ("Marking individual TypedDict items as required or potentially-missing").
+ :pep:`655` ("Marking individual TypedDict items as required or potentially missing").
.. versionadded:: 3.11
obtain the HTTP proxy's URL.
This example replaces the default :class:`ProxyHandler` with one that uses
-programmatically-supplied proxy URLs, and adds proxy authorization support with
+programmatically supplied proxy URLs, and adds proxy authorization support with
:class:`ProxyBasicAuthHandler`. ::
proxy_handler = urllib.request.ProxyHandler({'http': 'http://www.example.com:3128/'})
.. data:: NAMESPACE_DNS
- When this namespace is specified, the *name* string is a fully-qualified domain
+ When this namespace is specified, the *name* string is a fully qualified domain
name.
category must be a subclass in order to match.
* *module* is a string containing a regular expression that the start of the
- fully-qualified module name must match, case-sensitively. In :option:`-W` and
+ fully qualified module name must match, case-sensitively. In :option:`-W` and
:envvar:`PYTHONWARNINGS`, *module* is a literal string that the
- fully-qualified module name must be equal to (case-sensitively), ignoring any
+ fully qualified module name must be equal to (case-sensitively), ignoring any
whitespace at the start or end of *module*.
* *lineno* is an integer that the line number where the warning occurred must
.. method:: WSGIServer.get_app()
- Returns the currently-set application callable.
+ Returns the currently set application callable.
Normally, however, you do not need to use these additional methods, as
:meth:`set_app` is normally called by :func:`make_server`, and the
.. method:: BaseHandler.setup_environ()
- Set the :attr:`environ` attribute to a fully-populated WSGI environment. The
+ Set the :attr:`environ` attribute to a fully populated WSGI environment. The
default implementation uses all of the above methods and attributes, plus the
:meth:`get_stdin`, :meth:`get_stderr`, and :meth:`add_cgi_vars` methods and the
:attr:`wsgi_file_wrapper` attribute. It also inserts a ``SERVER_SOFTWARE`` key
entity expansion, too. Instead of nested entities it repeats one large entity
with a couple of thousand chars over and over again. The attack isn't as
efficient as the exponential case but it avoids triggering parser countermeasures
- that forbid deeply-nested entities.
+ that forbid deeply nested entities.
external entity expansion
Entity declarations can contain more than just text for replacement. They can
The following parameters govern the use of the returned proxy instance.
If *allow_none* is true, the Python constant ``None`` will be translated into
XML; the default behaviour is for ``None`` to raise a :exc:`TypeError`. This is
- a commonly-used extension to the XML-RPC specification, but isn't supported by
+ a commonly used extension to the XML-RPC specification, but isn't supported by
all clients and servers; see `http://ontosys.com/xml-rpc/extensions.php
<https://web.archive.org/web/20130120074804/http://ontosys.com/xml-rpc/extensions.php>`_
for a description.
A boolean indicating whether the end of the compressed data stream has been
reached.
- This makes it possible to distinguish between a properly-formed compressed
+ This makes it possible to distinguish between a properly formed compressed
stream, and an incomplete or truncated one.
.. versionadded:: 3.3
Typical implementations create a new instance of the class by invoking the
superclass's :meth:`__new__` method using ``super().__new__(cls[, ...])``
- with appropriate arguments and then modifying the newly-created instance
+ with appropriate arguments and then modifying the newly created instance
as necessary before returning it.
If :meth:`__new__` is invoked during object construction and it returns an
predictable between repeated invocations of Python.
This is intended to provide protection against a denial-of-service caused
- by carefully-chosen inputs that exploit the worst case performance of a
+ by carefully chosen inputs that exploit the worst case performance of a
dict insertion, O(n\ :sup:`2`) complexity. See
http://www.ocert.org/advisories/ocert-2011-003.html for details.
.. attribute:: __name__
- The ``__name__`` attribute must be set to the fully-qualified name of
+ The ``__name__`` attribute must be set to the fully qualified name of
the module. This name is used to uniquely identify the module in
the import system.
Top-level format specifiers may include nested replacement fields. These nested
fields may include their own conversion fields and :ref:`format specifiers
-<formatspec>`, but may not include more deeply-nested replacement fields. The
+<formatspec>`, but may not include more deeply nested replacement fields. The
:ref:`format specifier mini-language <formatspec>` is the same as that used by
the :meth:`str.format` method.
self.data = []
When a class defines an :meth:`__init__` method, class instantiation
-automatically invokes :meth:`__init__` for the newly-created class instance. So
+automatically invokes :meth:`__init__` for the newly created class instance. So
in this example, a new, initialized instance can be obtained by::
x = MyClass()
This is particularly useful in combination with the built-in function
:func:`vars`, which returns a dictionary containing all local variables.
-As an example, the following lines produce a tidily-aligned
+As an example, the following lines produce a tidily aligned
set of columns giving integers and their squares and cubes::
>>> for x in range(1, 11):
between repeated invocations of Python.
Hash randomization is intended to provide protection against a
- denial-of-service caused by carefully-chosen inputs that exploit the worst
+ denial-of-service caused by carefully chosen inputs that exploit the worst
case performance of a dict construction, O(n\ :sup:`2`) complexity. See
http://www.ocert.org/advisories/ocert-2011-003.html for details.
whether the actual warning category of the message is a subclass of the
specified warning category.
- The *module* field matches the (fully-qualified) module name; this match is
+ The *module* field matches the (fully qualified) module name; this match is
case-sensitive.
The *lineno* field matches the line number, where zero matches all line
of bug fixes and improvements are always being submitted. A host of minor fixes,
a few optimizations, additional docstrings, and better error messages went into
2.0; to list them all would be impossible, but they're certainly significant.
-Consult the publicly-available CVS logs if you want to see the full list. This
+Consult the publicly available CVS logs if you want to see the full list. This
progress is due to the five developers working for PythonLabs are now getting
paid to spend their days fixing bugs, and also due to the improved communication
resulting from moving to SourceForge.
of filters, and each filter can cause the :class:`LogRecord` to be ignored or
can modify the record before passing it along. When they're finally output,
:class:`LogRecord` instances are converted to text by a :class:`Formatter`
-class. All of these classes can be replaced by your own specially-written
+class. All of these classes can be replaced by your own specially written
classes.
With all of these features the :mod:`logging` package should provide enough
into this picture very well because they produce a Python list object containing
all of the items. This unavoidably pulls all of the objects into memory, which
can be a problem if your data set is very large. When trying to write a
-functionally-styled program, it would be natural to write something like::
+functionally styled program, it would be natural to write something like::
links = [link for link in get_all_links() if not link.followed]
for link in links:
(Contributed by Raymond Hettinger.)
-* Encountering a failure while importing a module no longer leaves a partially-initialized
+* Encountering a failure while importing a module no longer leaves a partially initialized
module object in ``sys.modules``. The incomplete module object left
behind would fool further imports of the same module into succeeding, leading to
confusing errors. (Fixed by Tim Peters.)
* The :mod:`tarfile` module now generates GNU-format tar files by default.
* Encountering a failure while importing a module no longer leaves a
- partially-initialized module object in ``sys.modules``.
+ partially initialized module object in ``sys.modules``.
* :const:`None` is now a constant; code that binds a new value to the name
``None`` is now a syntax error.
The changes in Python 2.5 are an interesting mix of language and library
improvements. The library enhancements will be more important to Python's user
-community, I think, because several widely-useful packages were added. New
+community, I think, because several widely useful packages were added. New
modules include ElementTree for XML processing (:mod:`xml.etree`),
the SQLite database module (:mod:`sqlite`), and the :mod:`ctypes`
module for calling C functions.
received several enhancements and a number of bugfixes. You can now set the
maximum size in bytes of a field by calling the
``csv.field_size_limit(new_limit)`` function; omitting the *new_limit*
- argument will return the currently-set limit. The :class:`reader` class now has
+ argument will return the currently set limit. The :class:`reader` class now has
a :attr:`line_num` attribute that counts the number of physical lines read from
the source; records can span multiple physical lines, so :attr:`line_num` is not
the same as the number of records read.
When you run Python, the module search path ``sys.path`` usually
includes a directory whose path ends in ``"site-packages"``. This
-directory is intended to hold locally-installed packages available to
+directory is intended to hold locally installed packages available to
all users using a machine or a particular site installation.
Python 2.6 introduces a convention for user-specific site directories.
The function must take a filename and return true if the file
should be excluded or false if it should be archived.
The function is applied to both the name initially passed to :meth:`add`
- and to the names of files in recursively-added directories.
+ and to the names of files in recursively added directories.
(All changes contributed by Lars Gustäbel).
(Contributed by Brett Cannon.)
* The :mod:`textwrap` module can now preserve existing whitespace
- at the beginnings and ends of the newly-created lines
+ at the beginnings and ends of the newly created lines
by specifying ``drop_whitespace=False``
as an argument::
ignores the insertion order and just compares the keys and values.
How does the :class:`~collections.OrderedDict` work? It maintains a
-doubly-linked list of keys, appending new keys to the list as they're inserted.
+doubly linked list of keys, appending new keys to the list as they're inserted.
A secondary dictionary maps keys to their corresponding list node, so
deletion doesn't have to traverse the entire linked list and therefore
remains O(1).
* :meth:`~unittest.TestCase.assertAlmostEqual` and :meth:`~unittest.TestCase.assertNotAlmostEqual` test
whether *first* and *second* are approximately equal. This method
- can either round their difference to an optionally-specified number
+ can either round their difference to an optionally specified number
of *places* (the default is 7) and compare it to zero, or require
the difference to be smaller than a supplied *delta* value.
* The :mod:`_winreg` module for accessing the registry now implements
the :func:`~_winreg.CreateKeyEx` and :func:`~_winreg.DeleteKeyEx`
- functions, extended versions of previously-supported functions that
+ functions, extended versions of previously supported functions that
take several extra arguments. The :func:`~_winreg.DisableReflectionKey`,
:func:`~_winreg.EnableReflectionKey`, and :func:`~_winreg.QueryReflectionKey`
were also tested and documented.
:data:`string.ascii_letters` etc. instead. (The reason for the
removal is that :data:`string.letters` and friends had
locale-specific behavior, which is a bad idea for such
- attractively-named global "constants".)
+ attractively named global "constants".)
* Renamed module :mod:`__builtin__` to :mod:`builtins` (removing the
underscores, adding an 's'). The :data:`__builtins__` variable
New typing features:
* :pep:`646`: Variadic generics.
-* :pep:`655`: Marking individual TypedDict items as required or potentially-missing.
+* :pep:`655`: Marking individual TypedDict items as required or potentially missing.
* :pep:`673`: ``Self`` type.
* :pep:`675`: Arbitrary literal string type.
Virtual environments help create separate Python setups while sharing a
system-wide base install, for ease of maintenance. Virtual environments
-have their own set of private site packages (i.e. locally-installed
+have their own set of private site packages (i.e. locally installed
libraries), and are optionally segregated from the system-wide site
packages. Their concept and implementation are inspired by the popular
``virtualenv`` third-party package, but benefit from tighter integration
lzma
----
-The newly-added :mod:`lzma` module provides data compression and decompression
+The newly added :mod:`lzma` module provides data compression and decompression
using the LZMA algorithm, including support for the ``.xz`` and ``.lzma``
file formats.
C-module and libmpdec written by Stefan Krah.
The new C version of the decimal module integrates the high speed libmpdec
-library for arbitrary precision correctly-rounded decimal floating point
+library for arbitrary precision correctly rounded decimal floating point
arithmetic. libmpdec conforms to IBM's General Decimal Arithmetic Specification.
Performance gains range from 10x for database applications to 100x for
in order to obtain a rounded or inexact value.
-* The power function in decimal.py is always correctly-rounded. In the
- C version, it is defined in terms of the correctly-rounded
+* The power function in decimal.py is always correctly rounded. In the
+ C version, it is defined in terms of the correctly rounded
:meth:`~decimal.Decimal.exp` and :meth:`~decimal.Decimal.ln` functions,
but the final result is only "almost always correctly rounded".
----
New attribute :attr:`zlib.Decompress.eof` makes it possible to distinguish
-between a properly-formed compressed stream and an incomplete or truncated one.
+between a properly formed compressed stream and an incomplete or truncated one.
(Contributed by Nadeem Vawda in :issue:`12646`.)
New attribute :attr:`zlib.ZLIB_RUNTIME_VERSION` reports the version string of
:keyword:`with` block becomes a "sub-test". This context manager allows a test
method to dynamically generate subtests by, say, calling the ``subTest``
context manager inside a loop. A single test method can thereby produce an
-indefinite number of separately-identified and separately-counted tests, all of
+indefinite number of separately identified and separately counted tests, all of
which will run even if one or more of them fail. For example::
class NumbersTest(unittest.TestCase):
``malloc`` in ``obmalloc``. Artificial benchmarks show about a 3% memory
savings.
-* :func:`os.urandom` now uses a lazily-opened persistent file descriptor
+* :func:`os.urandom` now uses a lazily opened persistent file descriptor
so as to avoid using many file descriptors when run in parallel from
multiple threads. (Contributed by Antoine Pitrou in :issue:`18756`.)
While Python provides a C API for thread-local storage support; the existing
:ref:`Thread Local Storage (TLS) API <thread-local-storage-api>` has used
:c:type:`int` to represent TLS keys across all platforms. This has not
-generally been a problem for officially-support platforms, but that is neither
+generally been a problem for officially support platforms, but that is neither
POSIX-compliant, nor portable in any practical sense.
:pep:`539` changes this by providing a new :ref:`Thread Specific Storage (TSS)
:issue:`31368`.)
The mode argument of :func:`os.makedirs` no longer affects the file
-permission bits of newly-created intermediate-level directories.
+permission bits of newly created intermediate-level directories.
(Contributed by Serhiy Storchaka in :issue:`19930`.)
:func:`os.dup2` now returns the new file descriptor. Previously, ``None``
(Contributed by Serhiy Storchaka in :issue:`29192`.)
* The *mode* argument of :func:`os.makedirs` no longer affects the file
- permission bits of newly-created intermediate-level directories.
+ permission bits of newly created intermediate-level directories.
To set their file permission bits you can set the umask before invoking
``makedirs()``.
(Contributed by Serhiy Storchaka in :issue:`19930`.)
.. nonce: qLkNh8
.. section: Library
-Enum: fix regression involving inheriting a multiply-inherited enum
+Enum: fix regression involving inheriting a multiply inherited enum
..
object referencing the ``Distribution`` when constructed from a
``Distribution``. - Add support for package discovery under package
normalization rules. - The object returned by ``metadata()`` now has a
-formally-defined protocol called ``PackageMetadata`` with declared support
+formally defined protocol called ``PackageMetadata`` with declared support
for the ``.get_all()`` method. - Synced with importlib_metadata 3.3.
..
.. section: Library
:mod:`argparse` raises :exc:`ValueError` with clear message when trying to
-render usage for an empty mutually-exclusive group. Previously it raised a
+render usage for an empty mutually exclusive group. Previously it raised a
cryptic :exc:`IndexError`.
..
.. nonce: 2PpaIN
.. section: Core and Builtins
-Deoptimize statically-allocated code objects during ``Py_FINALIZE()`` so
+Deoptimize statically allocated code objects during ``Py_FINALIZE()`` so
that future ``_PyCode_Quicken`` calls always start with unquickened code.
..
.. section: Library
The mode argument of os.makedirs() no longer affects the file permission
-bits of newly-created intermediate-level directories.
+bits of newly created intermediate-level directories.
..
.. nonce: gjm1LO
.. section: Core and Builtins
-Fix a possible segfault involving a newly-created coroutine. Patch by
+Fix a possible segfault involving a newly created coroutine. Patch by
Zackery Spytz.
..
.. section: Library
Fix C implementation of pickle.loads to use importlib's locking mechanisms,
-and thereby avoid using partially-loaded modules. Patch by Tim Burgess.
+and thereby avoid using partially loaded modules. Patch by Tim Burgess.
..