Created
March 20, 2018 09:54
-
-
Save NISH1001/9c394b350fa4b1cf9c6f8df72e9d63c9 to your computer and use it in GitHub Desktop.
abstract class in python
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
#!/usr/bin/env python3 | |
from abc import ABC, abstractmethod | |
class Base(ABC): | |
def __init__(self, val): | |
super().__init__() | |
self.val = val | |
@abstractmethod | |
def do_shit(self): | |
pass | |
class Derived(Base): | |
def __init(self, val): | |
pass | |
def do_shit(self): | |
print(self.val) | |
def main(): | |
d = Derived(2) | |
d.do_shit() | |
d.val = 3 | |
d.do_shit() | |
if __name__ == "__main__": | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment