for i in range(4): print i print "complete" x
Thanks for your reply. Well I get this behaviour consistently, and it can make it VERY difficult to debug because the Python window (for me, at least) ignores blank lines.Here's a sample script:for i in range(4): print i print "complete" xAs you can see, there are four lines. It's nice to have blank lines because it helps to organise the code.Naturally there is a deliberate error, and this is what the Python window says:>>> for i in range(4): ... print i ... print "complete" x ... Parsing error <type 'exceptions.SyntaxError'>: invalid syntax (line 3)It says the error is on line 3, when we all know it's on line 4. This is because the Python window ignores blank lines, either when you paste them in, or when you right click and choose Load to open a script.This is the behaviour that troubles me because all correspondence between errors and the original script is lost, and that is a bad thing because it's very hard to count lines in your original script editor. Any solutions?
>>> for i in range(4): ... print i ... print "complete" x ... Parsing error <type 'exceptions.SyntaxError'>: invalid syntax (line 3)
>>> for i in range(4): ... print i ... ... print "complete" x ... Parsing error SyntaxError: invalid syntax (line 4)
This is the behaviour that troubles me because all correspondence between errors and the original script is lost, and that is a bad thing because it's very hard to count lines in your original script editor. Any solutions?
As for your second question, I can't recall ever seeing a traceback with the wrong line number, regardless of the number of blank lines. Where are you seeing this happen?
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.