diff options
| author | Michel Albert <michel@albert.lu> | 2018-09-30 10:15:55 +0200 |
|---|---|---|
| committer | Michel Albert <michel@albert.lu> | 2018-09-30 10:15:55 +0200 |
| commit | d317977205763a34bb035b73ea6915e6bc62fb43 (patch) | |
| tree | de85dcf4a67c84b486db57d38c89196d1e0d3ccf /lib | |
| parent | 6b6b1a6e8d5d831fe17b168b4bf33d2c22bb2cc0 (diff) | |
| download | psycopg2-d317977205763a34bb035b73ea6915e6bc62fb43.tar.gz | |
Implement __str__ for range types
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/_range.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/_range.py b/lib/_range.py index fd15a76..30cda67 100644 --- a/lib/_range.py +++ b/lib/_range.py @@ -62,6 +62,19 @@ class Range(object): return "%s(%r, %r, %r)" % (self.__class__.__name__, self._lower, self._upper, self._bounds) + def __str__(self): + if (self._lower, self._upper, self._bounds) == (None, None, None): + return 'empty' + + items = [ + self._bounds[0], + str(self._lower), + ', ', + str(self._upper), + self._bounds[1] + ] + return ''.join(items) + @property def lower(self): """The lower bound of the range. `!None` if empty or unbound.""" |
