diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-12-19 06:09:46 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-19 06:09:46 (GMT) |
commit | 2b57c43f21f891df4c6f2294a3b9e1b9029a16b6 (patch) | |
tree | 0a875796fdcf96a15280d181efbf0c5fbb09eba6 /Doc/whatsnew | |
parent | 82d73554e4764350bfd8f13957c5e024ac95c4af (diff) | |
download | cpython-2b57c43f21f891df4c6f2294a3b9e1b9029a16b6.zip cpython-2b57c43f21f891df4c6f2294a3b9e1b9029a16b6.tar.gz cpython-2b57c43f21f891df4c6f2294a3b9e1b9029a16b6.tar.bz2 |
bpo-35506: Remove redundant and incorrect links from keywords. (GH-11174)
Diffstat (limited to 'Doc/whatsnew')
-rw-r--r-- | Doc/whatsnew/2.0.rst | 12 | ||||
-rw-r--r-- | Doc/whatsnew/2.1.rst | 4 | ||||
-rw-r--r-- | Doc/whatsnew/2.2.rst | 22 | ||||
-rw-r--r-- | Doc/whatsnew/2.3.rst | 16 | ||||
-rw-r--r-- | Doc/whatsnew/2.5.rst | 16 | ||||
-rw-r--r-- | Doc/whatsnew/2.6.rst | 14 | ||||
-rw-r--r-- | Doc/whatsnew/2.7.rst | 6 | ||||
-rw-r--r-- | Doc/whatsnew/3.0.rst | 12 | ||||
-rw-r--r-- | Doc/whatsnew/3.4.rst | 2 | ||||
-rw-r--r-- | Doc/whatsnew/3.7.rst | 2 | ||||
-rw-r--r-- | Doc/whatsnew/3.8.rst | 2 |
11 files changed, 54 insertions, 54 deletions
diff --git a/Doc/whatsnew/2.0.rst b/Doc/whatsnew/2.0.rst index 8c740ee..ace396b 100644 --- a/Doc/whatsnew/2.0.rst +++ b/Doc/whatsnew/2.0.rst @@ -284,7 +284,7 @@ write the following to do it:: L) Because of Python's scoping rules, a default argument is used so that the -anonymous function created by the :keyword:`lambda` statement knows what +anonymous function created by the :keyword:`lambda` expression knows what substring is being searched for. List comprehensions make this cleaner:: sublist = [ s for s in L if string.find(s, S) != -1 ] @@ -296,11 +296,11 @@ List comprehensions have the form:: for exprN in sequenceN if condition ] -The :keyword:`for`...\ :keyword:`in` clauses contain the sequences to be +The :keyword:`!for`...\ :keyword:`!in` clauses contain the sequences to be iterated over. The sequences do not have to be the same length, because they are *not* iterated over in parallel, but from left to right; this is explained more clearly in the following paragraphs. The elements of the generated list -will be the successive values of *expression*. The final :keyword:`if` clause +will be the successive values of *expression*. The final :keyword:`!if` clause is optional; if present, *expression* is only evaluated and added to the result if *condition* is true. @@ -316,7 +316,7 @@ following Python code:: # the expression to the # resulting list. -This means that when there are multiple :keyword:`for`...\ :keyword:`in` +This means that when there are multiple :keyword:`!for`...\ :keyword:`!in` clauses, the resulting list will be equal to the product of the lengths of all the sequences. If you have two lists of length 3, the output list is 9 elements long:: @@ -541,8 +541,8 @@ true if *obj* is present in the sequence *seq*; Python computes this by simply trying every index of the sequence until either *obj* is found or an :exc:`IndexError` is encountered. Moshe Zadka contributed a patch which adds a :meth:`__contains__` magic method for providing a custom implementation for -:keyword:`in`. Additionally, new built-in objects written in C can define what -:keyword:`in` means for them via a new slot in the sequence protocol. +:keyword:`!in`. Additionally, new built-in objects written in C can define what +:keyword:`!in` means for them via a new slot in the sequence protocol. Earlier versions of Python used a recursive algorithm for deleting objects. Deeply nested data structures could cause the interpreter to fill up the C stack diff --git a/Doc/whatsnew/2.1.rst b/Doc/whatsnew/2.1.rst index 12c028f..8b1eac9 100644 --- a/Doc/whatsnew/2.1.rst +++ b/Doc/whatsnew/2.1.rst @@ -52,7 +52,7 @@ The function :func:`g` will always raise a :exc:`NameError` exception, because the binding of the name ``g`` isn't in either its local namespace or in the module-level namespace. This isn't much of a problem in practice (how often do you recursively define interior functions like this?), but this also made using -the :keyword:`lambda` statement clumsier, and this was a problem in practice. +the :keyword:`lambda` expression clumsier, and this was a problem in practice. In code which uses :keyword:`lambda` you can often find local variables being copied by passing them as the default values of arguments. :: @@ -143,7 +143,7 @@ The syntax uses a ``from...import`` statement using the reserved module name While it looks like a normal :keyword:`import` statement, it's not; there are strict rules on where such a future statement can be put. They can only be at the top of a module, and must precede any Python code or regular -:keyword:`import` statements. This is because such statements can affect how +:keyword:`!import` statements. This is because such statements can affect how the Python bytecode compiler parses code and generates bytecode, so they must precede any statement that will result in bytecodes being produced. diff --git a/Doc/whatsnew/2.2.rst b/Doc/whatsnew/2.2.rst index c2ae866..b4cd434 100644 --- a/Doc/whatsnew/2.2.rst +++ b/Doc/whatsnew/2.2.rst @@ -121,7 +121,7 @@ added so if no built-in type is suitable, you can just subclass This means that :keyword:`class` statements that don't have any base classes are always classic classes in Python 2.2. (Actually you can also change this by setting a module-level variable named :attr:`__metaclass__` --- see :pep:`253` -for the details --- but it's easier to just subclass :keyword:`object`.) +for the details --- but it's easier to just subclass :class:`object`.) The type objects for the built-in types are available as built-ins, named using a clever trick. Python has always had built-in functions named :func:`int`, @@ -560,7 +560,7 @@ Here's the simplest example of a generator function:: yield i A new keyword, :keyword:`yield`, was introduced for generators. Any function -containing a :keyword:`yield` statement is a generator function; this is +containing a :keyword:`!yield` statement is a generator function; this is detected by Python's bytecode compiler which compiles the function specially as a result. Because a new keyword was introduced, generators must be explicitly enabled in a module by including a ``from __future__ import generators`` @@ -571,14 +571,14 @@ When you call a generator function, it doesn't return a single value; instead it returns a generator object that supports the iterator protocol. On executing the :keyword:`yield` statement, the generator outputs the value of ``i``, similar to a :keyword:`return` statement. The big difference between -:keyword:`yield` and a :keyword:`return` statement is that on reaching a -:keyword:`yield` the generator's state of execution is suspended and local +:keyword:`!yield` and a :keyword:`!return` statement is that on reaching a +:keyword:`!yield` the generator's state of execution is suspended and local variables are preserved. On the next call to the generator's ``next()`` method, -the function will resume executing immediately after the :keyword:`yield` -statement. (For complicated reasons, the :keyword:`yield` statement isn't -allowed inside the :keyword:`try` block of a +the function will resume executing immediately after the :keyword:`!yield` +statement. (For complicated reasons, the :keyword:`!yield` statement isn't +allowed inside the :keyword:`!try` block of a :keyword:`try`...\ :keyword:`finally` statement; read :pep:`255` for a full -explanation of the interaction between :keyword:`yield` and exceptions.) +explanation of the interaction between :keyword:`!yield` and exceptions.) Here's a sample usage of the :func:`generate_ints` generator:: @@ -602,7 +602,7 @@ generate_ints(3)``. Inside a generator function, the :keyword:`return` statement can only be used without a value, and signals the end of the procession of values; afterwards the -generator cannot return any further values. :keyword:`return` with a value, such +generator cannot return any further values. :keyword:`!return` with a value, such as ``return 5``, is a syntax error inside a generator function. The end of the generator's results can also be indicated by raising :exc:`StopIteration` manually, or by just letting the flow of execution fall off the bottom of the @@ -863,8 +863,8 @@ The function :func:`g` will always raise a :exc:`NameError` exception, because the binding of the name ``g`` isn't in either its local namespace or in the module-level namespace. This isn't much of a problem in practice (how often do you recursively define interior functions like this?), but this also made using -the :keyword:`lambda` statement clumsier, and this was a problem in practice. -In code which uses :keyword:`lambda` you can often find local variables being +the :keyword:`lambda` expression clumsier, and this was a problem in practice. +In code which uses :keyword:`!lambda` you can often find local variables being copied by passing them as the default values of arguments. :: def find(self, name): diff --git a/Doc/whatsnew/2.3.rst b/Doc/whatsnew/2.3.rst index 37ba7c0..dac0e63 100644 --- a/Doc/whatsnew/2.3.rst +++ b/Doc/whatsnew/2.3.rst @@ -149,7 +149,7 @@ Here's the simplest example of a generator function:: yield i A new keyword, :keyword:`yield`, was introduced for generators. Any function -containing a :keyword:`yield` statement is a generator function; this is +containing a :keyword:`!yield` statement is a generator function; this is detected by Python's bytecode compiler which compiles the function specially as a result. @@ -157,14 +157,14 @@ When you call a generator function, it doesn't return a single value; instead it returns a generator object that supports the iterator protocol. On executing the :keyword:`yield` statement, the generator outputs the value of ``i``, similar to a :keyword:`return` statement. The big difference between -:keyword:`yield` and a :keyword:`return` statement is that on reaching a -:keyword:`yield` the generator's state of execution is suspended and local +:keyword:`!yield` and a :keyword:`!return` statement is that on reaching a +:keyword:`!yield` the generator's state of execution is suspended and local variables are preserved. On the next call to the generator's ``.next()`` method, the function will resume executing immediately after the -:keyword:`yield` statement. (For complicated reasons, the :keyword:`yield` +:keyword:`!yield` statement. (For complicated reasons, the :keyword:`!yield` statement isn't allowed inside the :keyword:`try` block of a -:keyword:`try`...\ :keyword:`finally` statement; read :pep:`255` for a full -explanation of the interaction between :keyword:`yield` and exceptions.) +:keyword:`!try`...\ :keyword:`!finally` statement; read :pep:`255` for a full +explanation of the interaction between :keyword:`!yield` and exceptions.) Here's a sample usage of the :func:`generate_ints` generator:: @@ -188,7 +188,7 @@ generate_ints(3)``. Inside a generator function, the :keyword:`return` statement can only be used without a value, and signals the end of the procession of values; afterwards the -generator cannot return any further values. :keyword:`return` with a value, such +generator cannot return any further values. :keyword:`!return` with a value, such as ``return 5``, is a syntax error inside a generator function. The end of the generator's results can also be indicated by raising :exc:`StopIteration` manually, or by just letting the flow of execution fall off the bottom of the @@ -589,7 +589,7 @@ strict language such as Pascal would also prevent you performing arithmetic with Booleans, and would require that the expression in an :keyword:`if` statement always evaluate to a Boolean result. Python is not this strict and never will be, as :pep:`285` explicitly says. This means you can still use any expression -in an :keyword:`if` statement, even ones that evaluate to a list or tuple or +in an :keyword:`!if` statement, even ones that evaluate to a list or tuple or some random object. The Boolean type is a subclass of the :class:`int` class so that arithmetic using a Boolean still works. :: diff --git a/Doc/whatsnew/2.5.rst b/Doc/whatsnew/2.5.rst index f803a29..4e85aba 100644 --- a/Doc/whatsnew/2.5.rst +++ b/Doc/whatsnew/2.5.rst @@ -370,7 +370,7 @@ PEP 341: Unified try/except/finally Until Python 2.5, the :keyword:`try` statement came in two flavours. You could use a :keyword:`finally` block to ensure that code is always executed, or one or more :keyword:`except` blocks to catch specific exceptions. You couldn't -combine both :keyword:`except` blocks and a :keyword:`finally` block, because +combine both :keyword:`!except` blocks and a :keyword:`!finally` block, because generating the right bytecode for the combined version was complicated and it wasn't clear what the semantics of the combined statement should be. @@ -435,10 +435,10 @@ When you call ``counter(10)``, the result is an iterator that returns the values from 0 up to 9. On encountering the :keyword:`yield` statement, the iterator returns the provided value and suspends the function's execution, preserving the local variables. Execution resumes on the following call to the iterator's -:meth:`next` method, picking up after the :keyword:`yield` statement. +:meth:`next` method, picking up after the :keyword:`!yield` statement. In Python 2.3, :keyword:`yield` was a statement; it didn't return any value. In -2.5, :keyword:`yield` is now an expression, returning a value that can be +2.5, :keyword:`!yield` is now an expression, returning a value that can be assigned to a variable or otherwise operated on:: val = (yield i) @@ -458,7 +458,7 @@ expression on the right-hand side of an assignment. This means you can write Values are sent into a generator by calling its ``send(value)`` method. The generator's code is then resumed and the :keyword:`yield` expression returns the specified *value*. If the regular :meth:`next` method is called, the -:keyword:`yield` returns :const:`None`. +:keyword:`!yield` returns :const:`None`. Here's the previous example, modified to allow changing the value of the internal counter. :: @@ -644,7 +644,7 @@ Writing Context Managers ------------------------ Under the hood, the ':keyword:`with`' statement is fairly complicated. Most -people will only use ':keyword:`with`' in company with existing objects and +people will only use ':keyword:`!with`' in company with existing objects and don't need to know these details, so you can skip the rest of this section if you like. Authors of new objects will need to understand the details of the underlying implementation and should keep reading. @@ -750,9 +750,9 @@ generator function instead of defining a new class. The generator should yield exactly one value. The code up to the :keyword:`yield` will be executed as the :meth:`__enter__` method, and the value yielded will be the method's return value that will get bound to the variable in the ':keyword:`with`' statement's -:keyword:`as` clause, if any. The code after the :keyword:`yield` will be +:keyword:`!as` clause, if any. The code after the :keyword:`yield` will be executed in the :meth:`__exit__` method. Any exception raised in the block will -be raised by the :keyword:`yield` statement. +be raised by the :keyword:`!yield` statement. Our database example from the previous section could be written using this decorator as:: @@ -776,7 +776,7 @@ decorator as:: The :mod:`contextlib` module also has a ``nested(mgr1, mgr2, ...)`` function that combines a number of context managers so you don't need to write nested -':keyword:`with`' statements. In this example, the single ':keyword:`with`' +':keyword:`with`' statements. In this example, the single ':keyword:`!with`' statement both starts a database transaction and acquires a thread lock:: lock = threading.Lock() diff --git a/Doc/whatsnew/2.6.rst b/Doc/whatsnew/2.6.rst index ccfdbdc..512b8ed 100644 --- a/Doc/whatsnew/2.6.rst +++ b/Doc/whatsnew/2.6.rst @@ -250,10 +250,10 @@ PEP 343: The 'with' statement The previous version, Python 2.5, added the ':keyword:`with`' statement as an optional feature, to be enabled by a ``from __future__ import with_statement`` directive. In 2.6 the statement no longer needs to -be specially enabled; this means that :keyword:`with` is now always a +be specially enabled; this means that :keyword:`!with` is now always a keyword. The rest of this section is a copy of the corresponding section from the "What's New in Python 2.5" document; if you're -familiar with the ':keyword:`with`' statement +familiar with the ':keyword:`!with`' statement from Python 2.5, you can skip this section. The ':keyword:`with`' statement clarifies code that previously would use @@ -331,7 +331,7 @@ Writing Context Managers ------------------------ Under the hood, the ':keyword:`with`' statement is fairly complicated. Most -people will only use ':keyword:`with`' in company with existing objects and +people will only use ':keyword:`!with`' in company with existing objects and don't need to know these details, so you can skip the rest of this section if you like. Authors of new objects will need to understand the details of the underlying implementation and should keep reading. @@ -438,9 +438,9 @@ generator function instead of defining a new class. The generator should yield exactly one value. The code up to the :keyword:`yield` will be executed as the :meth:`__enter__` method, and the value yielded will be the method's return value that will get bound to the variable in the ':keyword:`with`' statement's -:keyword:`as` clause, if any. The code after the :keyword:`yield` will be +:keyword:`!as` clause, if any. The code after the :keyword:`!yield` will be executed in the :meth:`__exit__` method. Any exception raised in the block will -be raised by the :keyword:`yield` statement. +be raised by the :keyword:`!yield` statement. Using this decorator, our database example from the previous section could be written as:: @@ -464,7 +464,7 @@ could be written as:: The :mod:`contextlib` module also has a ``nested(mgr1, mgr2, ...)`` function that combines a number of context managers so you don't need to write nested -':keyword:`with`' statements. In this example, the single ':keyword:`with`' +':keyword:`with`' statements. In this example, the single ':keyword:`!with`' statement both starts a database transaction and acquires a thread lock:: lock = threading.Lock() @@ -1684,7 +1684,7 @@ Some smaller changes made to the core Python language are: * An obscure change: when you use the :func:`locals` function inside a :keyword:`class` statement, the resulting dictionary no longer returns free variables. (Free variables, in this case, are variables referenced in the - :keyword:`class` statement that aren't attributes of the class.) + :keyword:`!class` statement that aren't attributes of the class.) .. ====================================================================== diff --git a/Doc/whatsnew/2.7.rst b/Doc/whatsnew/2.7.rst index fd59c16..9f8d9f2 100644 --- a/Doc/whatsnew/2.7.rst +++ b/Doc/whatsnew/2.7.rst @@ -708,7 +708,7 @@ Some smaller changes made to the core Python language are: * The :keyword:`with` statement can now use multiple context managers in one statement. Context managers are processed from left to right - and each one is treated as beginning a new :keyword:`with` statement. + and each one is treated as beginning a new :keyword:`!with` statement. This means that:: with A() as a, B() as b: @@ -844,7 +844,7 @@ Some smaller changes made to the core Python language are: * The :keyword:`import` statement will no longer try an absolute import if a relative import (e.g. ``from .os import sep``) fails. This - fixes a bug, but could possibly break certain :keyword:`import` + fixes a bug, but could possibly break certain :keyword:`!import` statements that were only working by accident. (Fixed by Meador Inge; :issue:`7902`.) @@ -1158,7 +1158,7 @@ changes, or look through the Subversion logs for all the details. * Deprecated function: :func:`contextlib.nested`, which allows handling more than one context manager with a single :keyword:`with` - statement, has been deprecated, because the :keyword:`with` statement + statement, has been deprecated, because the :keyword:`!with` statement now supports multiple context managers. * The :mod:`cookielib` module now ignores cookies that have an invalid diff --git a/Doc/whatsnew/3.0.rst b/Doc/whatsnew/3.0.rst index 5ecf2eb..880958d 100644 --- a/Doc/whatsnew/3.0.rst +++ b/Doc/whatsnew/3.0.rst @@ -373,7 +373,7 @@ New Syntax * :pep:`3104`: :keyword:`nonlocal` statement. Using ``nonlocal x`` you can now assign directly to a variable in an outer (but - non-global) scope. :keyword:`nonlocal` is a new reserved word. + non-global) scope. :keyword:`!nonlocal` is a new reserved word. * :pep:`3132`: Extended Iterable Unpacking. You can now write things like ``a, b, *rest = some_sequence``. And even ``*rest, a = @@ -408,14 +408,14 @@ Changed Syntax * :pep:`3109` and :pep:`3134`: new :keyword:`raise` statement syntax: :samp:`raise [{expr} [from {expr}]]`. See below. -* :keyword:`as` and :keyword:`with` are now reserved words. (Since +* :keyword:`!as` and :keyword:`with` are now reserved words. (Since 2.6, actually.) * ``True``, ``False``, and ``None`` are reserved words. (2.6 partially enforced the restrictions on ``None`` already.) * Change from :keyword:`except` *exc*, *var* to - :keyword:`except` *exc* :keyword:`as` *var*. See :pep:`3110`. + :keyword:`!except` *exc* :keyword:`!as` *var*. See :pep:`3110`. * :pep:`3115`: New Metaclass Syntax. Instead of:: @@ -507,9 +507,9 @@ consulted for longer descriptions. * :ref:`pep-3105`. This is now a standard feature and no longer needs to be imported from :mod:`__future__`. More details were given above. -* :ref:`pep-3110`. The :keyword:`except` *exc* :keyword:`as` *var* - syntax is now standard and :keyword:`except` *exc*, *var* is no - longer supported. (Of course, the :keyword:`as` *var* part is still +* :ref:`pep-3110`. The :keyword:`except` *exc* :keyword:`!as` *var* + syntax is now standard and :keyword:`!except` *exc*, *var* is no + longer supported. (Of course, the :keyword:`!as` *var* part is still optional.) * :ref:`pep-3112`. The ``b"..."`` string literal notation (and its diff --git a/Doc/whatsnew/3.4.rst b/Doc/whatsnew/3.4.rst index 1099623..845e327 100644 --- a/Doc/whatsnew/3.4.rst +++ b/Doc/whatsnew/3.4.rst @@ -1352,7 +1352,7 @@ shelve ------ :class:`~shelve.Shelf` instances may now be used in :keyword:`with` statements, -and will be automatically closed at the end of the :keyword:`with` block. +and will be automatically closed at the end of the :keyword:`!with` block. (Contributed by Filip GruszczyĆski in :issue:`13896`.) diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst index 3e94a61..93d3e62 100644 --- a/Doc/whatsnew/3.7.rst +++ b/Doc/whatsnew/3.7.rst @@ -1896,7 +1896,7 @@ Deprecated Python Behavior Yield expressions (both ``yield`` and ``yield from`` clauses) are now deprecated in comprehensions and generator expressions (aside from the iterable expression -in the leftmost :keyword:`for` clause). This ensures that comprehensions +in the leftmost :keyword:`!for` clause). This ensures that comprehensions always immediately return a container of the appropriate type (rather than potentially returning a :term:`generator iterator` object), while generator expressions won't attempt to interleave their implicit output with the output diff --git a/Doc/whatsnew/3.8.rst b/Doc/whatsnew/3.8.rst index f4e6f64..2d45e7e 100644 --- a/Doc/whatsnew/3.8.rst +++ b/Doc/whatsnew/3.8.rst @@ -415,7 +415,7 @@ Changes in Python behavior * Yield expressions (both ``yield`` and ``yield from`` clauses) are now disallowed in comprehensions and generator expressions (aside from the iterable expression - in the leftmost :keyword:`for` clause). + in the leftmost :keyword:`!for` clause). (Contributed by Serhiy Storchaka in :issue:`10544`.) |