Created
September 19, 2022 17:16
-
-
Save s-hiiragi/91cd04ff06e074fb63d558c31c85b0cf to your computer and use it in GitHub Desktop.
オブジェクトのメソッドとプロパティを継承元ごとに表示
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_attrs(value): | |
from functools import reduce | |
mro = type(value).mro() | |
attrsets = [set(dir(x)) for x in mro] + [set()] | |
ownattrsets = [x - attrsets[i+1] for i,x in enumerate(attrsets) if i < len(mro)] | |
for type_, ownattrset in zip(mro, ownattrsets): | |
print(type_.__name__) | |
print(' ', list(ownattrset)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment