From b1953640d2ea42e7bab4cf63073c4fc26f3f895c Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Mon, 24 Sep 2012 00:46:43 +0100 Subject: [PATCH] Don't need to implement __new__ to make an immutable class --- lib/_range.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/_range.py b/lib/_range.py index a5cd3ae6..7fb194fb 100644 --- a/lib/_range.py +++ b/lib/_range.py @@ -55,8 +55,7 @@ class Range(object): """ __slots__ = ('_lower', '_upper', '_bounds') - def __new__(cls, lower=None, upper=None, bounds='[)', empty=False): - self = super(Range, cls).__new__(cls) + def __init__(self, lower=None, upper=None, bounds='[)', empty=False): if not empty: if bounds not in ('[)', '(]', '()', '[]'): raise ValueError("bound flags not valid: %r" % bounds) @@ -67,8 +66,6 @@ class Range(object): else: self._lower = self._upper = self._bounds = None - return self - def __repr__(self): if self._bounds is None: return "%s(empty=True)" % self.__class__.__name__