Skip to content

Instantly share code, notes, and snippets.

@Xevion
Created December 23, 2020 04:24
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 Xevion/e8677db28d50180412f2eaaad0180e4e to your computer and use it in GitHub Desktop.
Save Xevion/e8677db28d50180412f2eaaad0180e4e to your computer and use it in GitHub Desktop.
class InfiniteError(Exception):
def __init__(self, func):
super().__init__("Oops!")
func()
def func():
"""Very useful docstring.
Long enough so lemon approves.
"""
raise InfiniteError(func)
content = """class Oops(Exception):
\"\"\"Oops!\"\"\"
pass"""
import os, sys
# path to exception file
path = os.path.join(sys.path[0], 'exception.py')
for x in range(1,4378):
print(x)
# if arbitrary conditions apply
if (x % 7 == 0) and ((x * 2) % 19 == 0):
# open file, write our exception to it
file = open(path, 'w+')
file.write(content)
file.close()
# import exception then delete file
from exception import Oops
os.remove(path)
# Oops!
raise Oops('Oops!')
value = True
{True: 'String ok', False: 'String nok'}[value == 'ok']
('NOT OK', 'OK')[value == "ok"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment