improve abstract property support (closes #11610)

Thanks to Darren Dale for patch.
This commit is contained in:
Benjamin Peterson 2011-12-15 15:34:02 -05:00
parent a8ff01ca74
commit bfebb7b54a
12 changed files with 396 additions and 36 deletions

View file

@ -5,7 +5,7 @@
TODO: Fill out more detailed documentation on the operators."""
from abc import ABCMeta, abstractmethod, abstractproperty
from abc import ABCMeta, abstractmethod
__all__ = ["Number", "Complex", "Real", "Rational", "Integral"]
@ -50,7 +50,8 @@ class Complex(Number):
"""True if self != 0. Called for bool(self)."""
return self != 0
@abstractproperty
@property
@abstractmethod
def real(self):
"""Retrieve the real component of this number.
@ -58,7 +59,8 @@ class Complex(Number):
"""
raise NotImplementedError
@abstractproperty
@property
@abstractmethod
def imag(self):
"""Retrieve the imaginary component of this number.
@ -272,11 +274,13 @@ class Rational(Real):
__slots__ = ()
@abstractproperty
@property
@abstractmethod
def numerator(self):
raise NotImplementedError
@abstractproperty
@property
@abstractmethod
def denominator(self):
raise NotImplementedError