Insert some blank lines between methods (and remove a few between chapters).
This commit is contained in:
parent
66baf214a2
commit
2486b8db59
28
pep-3141.txt
28
pep-3141.txt
|
@ -83,6 +83,7 @@ numbers are supported by this hierarchy. ::
|
|||
special knowledge about them, it should fall back to the
|
||||
builtin complex type as described below.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def __complex__(self):
|
||||
"""Return a builtin complex instance."""
|
||||
|
@ -92,6 +93,7 @@ numbers are supported by this hierarchy. ::
|
|||
def real(self):
|
||||
"""Retrieve the real component of this number, which should subclass Real."""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
@property
|
||||
def imag(self):
|
||||
|
@ -101,15 +103,19 @@ numbers are supported by this hierarchy. ::
|
|||
@abstractmethod
|
||||
def __add__(self, other):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def __sub__(self, other):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def __neg__(self):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def __mul__(self, other):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def __div__(self, other):
|
||||
raise NotImplementedError
|
||||
|
@ -127,6 +133,7 @@ numbers are supported by this hierarchy. ::
|
|||
@abstractmethod
|
||||
def __eq__(self, other):
|
||||
raise NotImplementedError
|
||||
|
||||
def __ne__(self, other):
|
||||
return not (self == other)
|
||||
|
||||
|
@ -143,6 +150,7 @@ totally ordered. (NaNs were handled above).::
|
|||
|
||||
Real also provides defaults for the derived operations.
|
||||
"""
|
||||
|
||||
@abstractmethod
|
||||
def __float__(self):
|
||||
"""Any Real can be converted to a native float object."""
|
||||
|
@ -156,10 +164,12 @@ totally ordered. (NaNs were handled above).::
|
|||
def __divmod__(self, other):
|
||||
"""The pair (self // other, self % other)."""
|
||||
return (self // other, self % other)
|
||||
|
||||
@abstractmethod
|
||||
def __floordiv__(self, other):
|
||||
"""The floor() of self/other."""
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def __mod__(self, other):
|
||||
"""."""
|
||||
|
@ -168,6 +178,7 @@ totally ordered. (NaNs were handled above).::
|
|||
@abstractmethod
|
||||
def __lt__(self, other):
|
||||
raise NotImplementedError
|
||||
|
||||
def __le__(self, other):
|
||||
# Assume that if other is Real, it defines an ordering
|
||||
# consistent with this class, or returns NotImplemented.
|
||||
|
@ -175,11 +186,14 @@ totally ordered. (NaNs were handled above).::
|
|||
return not (other < self)
|
||||
|
||||
# Concrete implementations of Complex abstract methods.
|
||||
|
||||
def __complex__(self):
|
||||
return complex(float(self))
|
||||
|
||||
@property
|
||||
def real(self):
|
||||
return self
|
||||
|
||||
@property
|
||||
def imag(self):
|
||||
return 0
|
||||
|
@ -191,10 +205,12 @@ the stdlib?::
|
|||
|
||||
class Rational(Real, Exact):
|
||||
""".numerator and .denominator should be in lowest terms."""
|
||||
|
||||
@abstractmethod
|
||||
@property
|
||||
def numerator(self):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
@property
|
||||
def denominator(self):
|
||||
|
@ -209,6 +225,7 @@ And finally integers::
|
|||
|
||||
class Integral(Rational):
|
||||
"""Integral adds a conversion to int and the bit-string operations."""
|
||||
|
||||
@abstractmethod
|
||||
def __int__(self):
|
||||
raise NotImplementedError
|
||||
|
@ -216,32 +233,37 @@ And finally integers::
|
|||
@abstractmethod
|
||||
def __lshift__(self, other):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def __rshift__(self, other):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def __and__(self, other):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def __xor__(self, other):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def __or__(self, other):
|
||||
raise NotImplementedError
|
||||
|
||||
# Concrete implementations of Rational and Real abstract methods.
|
||||
|
||||
def __float__(self):
|
||||
return float(int(self))
|
||||
|
||||
@property
|
||||
def numerator(self):
|
||||
return self
|
||||
|
||||
@property
|
||||
def denominator(self):
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
|
||||
Exact vs. Inexact Classes
|
||||
-------------------------
|
||||
|
||||
|
@ -295,6 +317,7 @@ and do the operation there. For subtypes of Integral, this means that
|
|||
__add__ and __radd__ should be defined as::
|
||||
|
||||
class MyIntegral(Integral):
|
||||
|
||||
def __add__(self, other):
|
||||
if isinstance(other, MyIntegral):
|
||||
return do_my_adding_stuff(self, other)
|
||||
|
@ -302,6 +325,7 @@ __add__ and __radd__ should be defined as::
|
|||
return do_my_other_adding_stuff(self, other)
|
||||
else:
|
||||
return NotImplemented
|
||||
|
||||
def __radd__(self, other):
|
||||
if isinstance(other, MyIntegral):
|
||||
return do_my_adding_stuff(other, self)
|
||||
|
|
Loading…
Reference in New Issue