[issue29459] `__contains__` and `get` methods for match objects?

2017-02-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: +1 for m.get(key[, default]) -1 for __contains__ The get() makes logical sense and it is perfectly reasonable to want a default value for a missing group. The contains idea makes less sense and is problematic on several fronts. "'a' in match" only works

[issue29459] `__contains__` and `get` methods for match objects?

2017-02-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I predicted that that change will open a can of worms. The match object is not a dictionary. I don't see a need in new methods. The get() method you propose looks virtually the same as the group() method. "'a' in match" is virtually the same as

[issue29459] `__contains__` and `get` methods for match objects?

2017-02-06 Thread irdb
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 =