I'm trying to implement a simple Hello World program in Python. The following code prints "Hello World" just fine:
def main(data=[72, 29, 7, 0, 3, -79, 55, 24, 3, -6, -8]):
print(chr(data[0]), end="")
if len(data) > 1:
data[0] += data.pop(1)
raise Exception()
if __name__ == "__main__":
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
main()
...but when I try to add an exclamation point at the end, like this:
def main(data=[72, 29, 7, 0, 3, -79, 55, 24, 3, -6, -8, -67]):
if len(data) > 1:
data[0] += data.pop(1)
raise Exception()
if __name__ == "__main__":
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
try:
main()
except Exception as e:
main()
...I get a Fatal Python error: XXX block stack overflow
.
I've tried adding more try/except clauses to catch the block stack overflow error, but nothing seems to work. What the heck is the block stack, and why would such a straightforward approach not work?