Created
February 13, 2018 16:06
-
-
Save mingrui/86ea9513f286fba7459cbafbbc5d5470 to your computer and use it in GitHub Desktop.
testing abc
This file contains 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
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