Am I not seeing the Error?

Ned Batchelder ned at nedbatchelder.com
Mon Aug 12 10:01:55 EDT 2013


On 8/12/13 8:33 AM, Devyn Collier Johnson wrote:
>
> On 08/10/2013 10:47 PM, Chris Angelico wrote:
>> On Sun, Aug 11, 2013 at 3:43 AM, Roy Smith <roy at panix.com> wrote:
>>> In article <mailman.452.1376188442.1251.python-list at python.org>,
>>>   Chris Angelico <rosuav at gmail.com> wrote:
>>>
>>>> When you get a syntax error you can't understand, look at the previous
>>>> line of code. Perhaps something there is incomplete; maybe you have
>>>> mismatched parentheses, so this line is considered to be part of the
>>>> same expression.
>>>>
>>>> Next thing to do is split it into more lines. Why is all that in a 
>>>> single
>>>> line?
>>> Also, try reformatting the code in a tool like emacs or eclipse which
>>> does syntax coloring and auto indenting.  Often, if you're missing some
>>> piece of punctuation, it will become obvious when your tool tries to
>>> indent things in some unexpected way.  Or suddenly starts coloring all
>>> of your program text as if it were a string literal :-)
>> Agreed. Though I've had some odd issues with SciTE in that way; I
>> think its Python handling may have bugs in it here and there. But 95%
>> of the time it's helpful.
>>
>> ChrisA
>
> Thanks everyone. Unfortunately, I have not found the problem yet. I 
> use the Geany IDE which has syntax highlighting, but nothing wrong is 
> seen. None of the suggestions helped. The lines before this one set 
> variables. The lines further up "appear" fine. I will keep looking. If 
> I ever figure it out, I will share with all of you.
>
As Terry Reedy pointed out, you have semicolons separating arguments in 
a function call.  This is your line of code:

JOB_WRITEURGFILES = 
multiprocessing.Process(write2file('./mem/ENGINE_PID', ENGINEPID); 
write2file(SENTEMPPATH, ''); write2file(INPUTMEM, '')); 
JOB_WRITEURGFILES.start()

Replacing names with shorter ones to see the structure, it's like this:

J = m.P( w('', E); w(S, ''); w(I, '') ); J.s()

You have three semicolons in that line.  Two are inside a call, though 
I'm not sure that's what you intended.  One is separating statements.  
You might be a little too attached to your "more readable" style.  
Putting things on different lines really does help you see what is going on.

--Ned.




More information about the Python-list mailing list