Created on 2018-09-11 21:35 by iomintz, last changed 2022-04-11 14:59 by admin. This issue is now closed.
Pull Requests |
|
|
|
URL |
Status |
Linked |
Edit |
PR 9186 |
closed |
iomintz,2018-09-11 21:36 |
|
Messages (4) |
|
|
msg325068 - (view) |
Author: Io Mintz (iomintz) * |
Date: 2018-09-11 21:35 |
Adds inspect.getsubclasses, inspect.getallsubclasses (recursive), and inspect.getsubclasstree (recursive, maintains structure). See documentation for more details. |
|
|
msg325298 - (view) |
Author: Petr Viktorin (petr.viktorin) *  |
Date: 2018-09-13 22:04 |
What's the use case for these? |
|
|
msg325317 - (view) |
Author: Io Mintz (iomintz) * |
Date: 2018-09-14 03:09 |
I didn't have one in mind. I just noticed that there was a getmro which accessed __mro__ but no corresponding method for __subclasses__. That got me getsubclasses and getallsubclasses. Then I thought it would be cool if you could walk the tree of subclasses in code, so I wrote getsubclasstree. |
|
|
msg325318 - (view) |
Author: Petr Viktorin (petr.viktorin) *  |
Date: 2018-09-14 03:34 |
__subclasses__ is, as Tim Peters put it [0], "just Python exposing an internal mechanism for the morbidly curious". I'd expect that not all alternative implementations of Python have something like __subclasses__ -- it's a detail of the implementation (as opposed to the MRO, which is something any implementation of the Python language needs to be able to compute). It certainly is cool functionality, but keep in mind we'd have to support it for decades, and it would put pressure on other Python implementations to add something like __subclasses__. With that in mind, and because there's no real use case, I think it's better to not add this to inspect. [0] https://mail.python.org/pipermail/python-list/2003-August/210297.html |
|
|
History |
|
|
|
Date |
User |
Action |
Args |
2022-04-11 14:59:05 |
admin |
set |
github: 78816 |
2018-09-14 03:46:55 |
iomintz |
set |
status: open -> closedstage: patch review -> resolved |
2018-09-14 03:34:53 |
petr.viktorin |
set |
messages: + |
2018-09-14 03:09:38 |
iomintz |
set |
messages: + |
2018-09-13 22:04:04 |
petr.viktorin |
set |
nosy: + petr.viktorinmessages: + |
2018-09-11 21:38:49 |
zach.ware |
set |
nosy: + yselivanov |
2018-09-11 21:36:23 |
iomintz |
set |
keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest8623> |
2018-09-11 21:35:42 |
iomintz |
create |
|