Last active
November 30, 2025 17:41
-
-
Save ptmcg/06c63feeb6ad027d4c9d1f381af1a8a3 to your computer and use it in GitHub Desktop.
Recreate popular verses on love from I Corinthians
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
| # | |
| # corinthians_I.py | |
| # | |
| # Class definitions to use when recreating I Corinthians 13:4-8 from | |
| # the Python prompt. | |
| # | |
| # Copyright 2020, Paul McGuire | |
| # | |
| import sys | |
| sys.excepthook = lambda *args: print(args[0].__name__) | |
| class Evil: | |
| pass | |
| class Love: | |
| def envy(self): | |
| raise NotImplementedError | |
| def boast(self): | |
| raise NotImplementedError | |
| def dishonor(self, *args): | |
| raise NotImplementedError | |
| def fail(self): | |
| raise NotImplementedError | |
| def protect(self): | |
| pass | |
| def trust(self): | |
| pass | |
| def hope(self): | |
| pass | |
| def persevere(self): | |
| pass | |
| def seek(self, obj): | |
| if obj is self: | |
| raise ValueError | |
| def anger(self): | |
| raise TimeoutError | |
| def delight(self, obj): | |
| if isinstance(obj, Evil): | |
| raise TypeError | |
| def rejoice(self, obj): | |
| return bool(obj) | |
| evil = Evil() | |
| love = Love() | |
| patient = love | |
| kind = love | |
| proud = None | |
| others = [] | |
| truth = True | |
| verses = """\ | |
| love is patient | |
| love is kind | |
| love.envy() | |
| love.boast() | |
| love is proud | |
| love.dishonor(others) | |
| love.seek(love) | |
| love.anger() | |
| love.delight(evil) | |
| love.rejoice(truth) | |
| love.protect() | |
| love.trust() | |
| love.hope() | |
| love.persevere() | |
| love.fail()""" | |
| for verse in verses.splitlines(): | |
| print(verse) | |
| try: | |
| eval(verse) | |
| except Exception as e: | |
| print(type(e).__name__) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment