Skip to content

Instantly share code, notes, and snippets.

@mingrui
Created February 13, 2018 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mingrui/86ea9513f286fba7459cbafbbc5d5470 to your computer and use it in GitHub Desktop.
Save mingrui/86ea9513f286fba7459cbafbbc5d5470 to your computer and use it in GitHub Desktop.
testing abc
import abc
#class Base1(metaclass=abc.ABCMeta):
class Base1():
class_variable_one = 0
@abc.abstractmethod
def test_func(self):
pass
class Derived1(Base1):
def __init__(self):
print(Base1.class_variable_one)
self.class_variable_one = 1
def get_base(self):
return Base1
class Derived2(Base1):
def __init__(self):
print(Base1.class_variable_one)
self.class_variable_one = 2
if __name__ == '__main__':
base1 = Base1()
print(base1.class_variable_one)
derived1 = Derived1()
print(derived1.class_variable_one)
derived2 = Derived2()
print(derived2.class_variable_one)
print(base1.class_variable_one)
print(derived1.class_variable_one)
print(derived2.class_variable_one)
print('\n')
print(derived1.get_base().class_variable_one)
print(derived1.class_variable_one)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment