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 <rep...@bugs.python.org>
<http://bugs.python.org/issue29459>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to