[Python-checkins] r56637 - peps/trunk/pep-3141.txt
guido.van.rossum
python-checkins at python.org
Tue Jul 31 23:14:19 CEST 2007
Author: guido.van.rossum
Date: Tue Jul 31 23:14:18 2007
New Revision: 56637
Modified:
peps/trunk/pep-3141.txt
Log:
Insert some blank lines between methods (and remove a few between chapters).
Modified: peps/trunk/pep-3141.txt
==============================================================================
--- peps/trunk/pep-3141.txt (original)
+++ peps/trunk/pep-3141.txt Tue Jul 31 23:14:18 2007
@@ -83,6 +83,7 @@
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 @@
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 @@
@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 @@
@abstractmethod
def __eq__(self, other):
raise NotImplementedError
+
def __ne__(self, other):
return not (self == other)
@@ -143,6 +150,7 @@
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 @@
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 @@
@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 @@
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 @@
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 @@
class Integral(Rational):
"""Integral adds a conversion to int and the bit-string operations."""
+
@abstractmethod
def __int__(self):
raise NotImplementedError
@@ -216,32 +233,37 @@
@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 @@
__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 @@
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)
More information about the Python-checkins
mailing list