[pythonvis] Re: print"Hello world."

  • From: James Scholes <james@xxxxxxxxxxxxx>
  • To: pythonvis@xxxxxxxxxxxxx
  • Date: Tue, 29 Apr 2014 19:14:53 +0100

Richard Dinger wrote:
> I was unable to replicate your example.  The first correct print
> statement did not print, I only got the error traceback.

I should've realised that a syntax error would prevent the program from
running at all.  However, a traceback does not.  For example, if you run
the following code:

print "Hello world!"
print "Here comes a traceback when we try to divide by zero..."
print 20 / 0

You will see:

Hello world!
Here comes a traceback when we try to divide by zero...
Traceback (most recent call last):
  File "hello.py", line 3, in <module>
    print 20 / 0
ZeroDivisionError: integer division or modulo by zero

You cannot divide a number by zero, so your program crashes and
generates a traceback.  However, as you can see, the file is
syntactically correct, so the statements up to that point will run
without a problem.  Apologies for the error!
-- 
James Scholes
http://twitter.com/JamesScholes

Other related posts: