Skip to content

Instantly share code, notes, and snippets.

@NISH1001
Created March 20, 2018 09:54
Show Gist options
  • Save NISH1001/9c394b350fa4b1cf9c6f8df72e9d63c9 to your computer and use it in GitHub Desktop.
Save NISH1001/9c394b350fa4b1cf9c6f8df72e9d63c9 to your computer and use it in GitHub Desktop.
abstract class in python
#!/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