Python Programming



Ctrl + C Doesn’t Work?!

Interesting nested try except code – why? Because we can…

def main():
	try:
		while 1:
			print "hi"
	except KeyboardInterrupt:
		try:
			while 1:
				print "ho"
		except KeyboardInterrupt:
			try:
				while 1:
					print "ha"
			except KeyboardInterrupt:
				try:
					while 1:
						print "he"
				except KeyboardInterrupt:
					try:
						while 1:
							print "hu"
					except KeyboardInterrupt:
						while 1:
							print "eeek"


Leave a comment