Skip to content

Instantly share code, notes, and snippets.

@cdennison
Created July 29, 2017 15:00
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 cdennison/6df7d2120da9a9d10092f413babd2028 to your computer and use it in GitHub Desktop.
Save cdennison/6df7d2120da9a9d10092f413babd2028 to your computer and use it in GitHub Desktop.

class Document: def init(self, name): self.name = name

def show(self):
    raise NotImplementedError("Subclass must implement abstract method")

class Pdf(Document): def show(self): return 'Show pdf contents!'

class Word(Document): def show(self): return 'Show word contents!'

documents = [Pdf('Document1'), Pdf('Document2'), Word('Document3')]

print(type(documents)) for document in documents: print (document.name + ': ' + document.show(),type(document))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment