Issue 22268: add dedicated functions mrohasattr and mrogetattr (original) (raw)

Issue22268

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:07 admin set github: 66464
2021-10-21 19:20:23 iritkatriel set status: open -> closedresolution: rejectedstage: resolved
2016-01-05 22:23:45 gvanrossum set nosy: + gvanrossummessages: +
2016-01-05 22:12:20 abarnert set nosy: + abarnertmessages: +
2015-03-07 16:13:23 BreamoreBoy set title: mrohasattr and mrogetattr -> add dedicated functions mrohasattr and mrogetattr
2014-08-24 22:17:47 Gregory.Salvan create