This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: add dedicated functions mrohasattr and mrogetattr
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Gregory.Salvan, abarnert, gvanrossum
Priority: normal Keywords: patch

Created on 2014-08-24 22:17 by Gregory.Salvan, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
mroattr.patch Gregory.Salvan, 2014-08-24 22:17 review
Messages (3)
msg225842 - (view) Author: Gregory Salvan (Gregory.Salvan) Date: 2014-08-24 22:17
It's a small refactoring.

Lurking at collections.abc I found a lot of: 
>>> any(attr in B.__dict__ for B in C.__mro__)

also repeated in typing.py of mypy:
https://github.com/JukkaL/mypy/blob/master/lib-typing/3.2/typing.py#L117

It seems to be a common operation to check or get an attribute from mro in abc, so I thought it could help to have dedicated functions to enhance readability.
(see patch e.g. Hash.__subclasshook__ takes 1 line intead of 7...)
msg257560 - (view) Author: Andrew Barnert (abarnert) * Date: 2016-01-05 22:12
See #25958, which incorporates a similar refactoring in service of making all of the subclasshooks in collections.abc handle None the same way.

We definitely do want something public in the abc module like this, rather than the private function in collections.abc that I wrote, especially given the discussion about moving a bunch of the ABCs to other modules.
msg257561 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2016-01-05 22:23
Honestly I don't think this is worth it. The proposed functions seem to fall firmly in the territory of "not every three useful lines of code are worth a stdlib function".
History
Date User Action Args
2022-04-11 14:58:07adminsetgithub: 66464
2021-10-21 19:20:23iritkatrielsetstatus: open -> closed
resolution: rejected
stage: resolved
2016-01-05 22:23:45gvanrossumsetnosy: + gvanrossum
messages: + msg257561
2016-01-05 22:12:20abarnertsetnosy: + abarnert
messages: + msg257560
2015-03-07 16:13:23BreamoreBoysettitle: mrohasattr and mrogetattr -> add dedicated functions mrohasattr and mrogetattr
2014-08-24 22:17:47Gregory.Salvancreate