PEP 532: typo fixes

This commit is contained in:
Nick Coghlan 2016-11-05 19:49:37 +10:00
parent 9f8dddecc0
commit 0861d8e114
1 changed files with 7 additions and 7 deletions

View File

@ -312,7 +312,7 @@ reasons:
* defining a shared protocol for both ``and`` and ``or`` was confusing, as
``__then__`` was the short-circuiting outcome for ``or``, while ``__else__``
was the short-circuiting outcome for ``__and__``
was the short-circuiting outcome for ``and``
* the ``and`` and ``or`` operators have a long established and stable meaning,
so readers would inevitably be surprised if their meaning now became
dependent on the type of the left operand. Even new users would be confused
@ -338,17 +338,17 @@ as circuit breaker definitions if we chose to do so::
class true(types.CircuitBreaker):
"""Circuit breaker for 'bool(EXPR)' checks"""
def __init__(self, value):
super().__init__(value, bool(value), when_false)
super().__init__(value, bool(value), false)
class false(types.CircuitBreaker):
"""Circuit breaker for 'not bool(EXPR)' checks"""
def __init__(self, value):
super().__init__(value, not bool(value), when_true)
super().__init__(value, not bool(value), true)
Given those circuit breakers:
* ``LHS or RHS`` would be roughly ``operator.true(LHS) else RHS``
* ``LHS and RHS`` would be roughly ``opreator.false(LHS) else RHS``
* ``LHS and RHS`` would be roughly ``operator.false(LHS) else RHS``
Naming the operator and protocol
@ -389,7 +389,7 @@ In ultimately rejecting PEP 335, Guido van Rossum noted [1_]:
The NumPy folks brought up a somewhat separate issue: for them,
the most common use case is chained comparisons (e.g. A < B < C).
To understand this obversation, we first need to look at how comparisons work
To understand this observation, we first need to look at how comparisons work
with NumPy arrays::
>>> import numpy as np
@ -403,8 +403,8 @@ with NumPy arrays::
array([ True, True, False, False, False], dtype=bool)
Here we see that NumPy array comparisons are element-wise by default, comparing
each element in the lefthand array to the corresponding element in the righthand
array, and producing a matrix of boolean results.
each element in the left hand array to the corresponding element in the right
hand array, and producing a matrix of boolean results.
If either side of the comparison is a scalar value, then it is broadcast across
the array and compared to each individual element::