Skip to content

Instantly share code, notes, and snippets.

@jerome-diver
Created May 28, 2019 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jerome-diver/d1eae1827006862563a6af10375303ed to your computer and use it in GitHub Desktop.
Save jerome-diver/d1eae1827006862563a6af10375303ed to your computer and use it in GitHub Desktop.
"""Please, let me know which child is calling me: 'parent' ? """
def read_childs(cls):
"""Return childs of cls"""
return cls.__subclasses__()
class A:
"""This is a mixin class to share code for DRY"""
def __init__(self, var=None):
my_childs_are = red_childs(self) # it may be [childs_list_if_any]
if "Child1" in my_childs_are:
print("youpi... there is Child1 call me")
else:
print("let's do what i want there also please... i'm open mind, do you ?")
class Child1(A):
"""I'm a child of Mixin class A"""
def __init__(self, var):
super().__init__(var)
print("i can not show my ass, but maybe my parent can know me... what do you think ? possible or not ?")
class Child2(A):
"""I'm an other child of Mixin A"""
def __init__(self, var):
super().__init__(var)
print("is it clear for you know about what i want to get there ?")
class Child3(A):
"""You should see that i am also a child of A possibly..."
def __init__(self, var):
super().__init__(var)
print("Don't tell me to not do that if you don't know how to do that please, that doesn't halp me.")
print("imagine i just want to know how to do that and not trash patatoes... do YOU know how to do please?"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment