Skip to content

Instantly share code, notes, and snippets.

@ptmcg
Last active November 30, 2025 17:41
Show Gist options
  • Select an option

  • Save ptmcg/06c63feeb6ad027d4c9d1f381af1a8a3 to your computer and use it in GitHub Desktop.

Select an option

Save ptmcg/06c63feeb6ad027d4c9d1f381af1a8a3 to your computer and use it in GitHub Desktop.
Recreate popular verses on love from I Corinthians
#
# 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