[New-bugs-announce] [issue29459] `__contains__` and `get` methods for match objects?

irdb report at bugs.python.org
Mon Feb 6 03:00:11 EST 2017


New submission from irdb:

__getitem__ was added to match objects as a resolution of issue24454.

Wouldn't it be nice to also have `__contains__` and `get` methods for match objects? Is it even feasible to implement them in neat way?

They should work similar to dictionaries, i.e:

```
match = re.match('(?P<a>a)', 'a')
match.get('b')  # should return None
match.get(1)  # should return 'a'
'a' in match # True
'b' in match # False
```

----------
components: Library (Lib)
messages: 287096
nosy: eric.smith, irdb, mrabarnett, serhiy.storchaka
priority: normal
severity: normal
status: open
title: `__contains__` and `get` methods for match objects?
type: enhancement
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29459>
_______________________________________


More information about the New-bugs-announce mailing list