diff options
author | Guido van Rossum <guido@python.org> | 1997-07-15 15:40:29 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-07-15 15:40:29 (GMT) |
commit | 531097502cc549a8ec5bbe29c90e7b8850cbff24 (patch) | |
tree | 373b6c76b5c001cc3101c3e8faac3d54926ba825 | |
parent | 09bcfd649abcbca173ea463a799193c3026e2666 (diff) | |
download | cpython-531097502cc549a8ec5bbe29c90e7b8850cbff24.zip cpython-531097502cc549a8ec5bbe29c90e7b8850cbff24.tar.gz cpython-531097502cc549a8ec5bbe29c90e7b8850cbff24.tar.bz2 |
Fix group() -- should be tuple even when re has exactly one group.
-rw-r--r-- | Lib/re.py | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -160,6 +160,9 @@ class MatchObject: def group(self, *groups): if len(groups) == 0: groups = range(1, self.re.num_regs) + use_all = 1 + else: + use_all = 0 result = [] for g in groups: if type(g) == type(''): @@ -171,7 +174,7 @@ class MatchObject: result.append(None) else: result.append(self.string[self.regs[g][0]:self.regs[g][1]]) - if len(result) > 1: + if use_all or len(result) > 1: return tuple(result) elif len(result) == 1: return result[0] |