"""Exceptions"""

def assert_false():
	assert False, 'False!'

def errors():
	abs('hello')  # TypeError
	hello  # NameError
	{}['hello']  # KeyError
	def f(): f()
	f()  # RuntimeError

def invert(x):
	"""Return 1/x

	>>> invert(2)
	Never printed if x is 0
	0.5
	"""
	result = 1 / x  # Raises a ZeroDivisionError if x is 0.
	print('Never printed if x is 0')
	return result

def invert_safe(x):
	"""Return 1/x, or the string 'division by zero' if x is 0.

	>>> invert_safe(2)
	Never printed if x is 0
	0.5
	>>> invert_safe(0)
	Handled division by zero
	"""
	try:
		return invert(x)
	except ZeroDivisionError as e:
		print('Handled', e)
