Select to view content in your preferred language

Python Scripting Problem

895
2
11-12-2013 09:39 PM
H_A_D_Padmasiri
New Contributor
I wrote a python script. when it run the following message display

SyntaxError: unexpected character after line continuation character (Script1.py, line 29)
Failed to execute (LISTool1.0).

I cant understand what,s wrong with my script

Can you help me

Thanks
Tags (2)
0 Kudos
2 Replies
T__WayneWhitley
Frequent Contributor
The line that includes your query is escaping quotes wrong-- this doesn't work:

" " \Layer\ " LIKE 'BOUND%'  AND " \Layer\ " NOT LIKE 'BOUND-ADMIN-VIR' "

The quote escape works like this:  \"  ...or this:  \'

So try this:
" \"Layer\" LIKE 'BOUND%'  AND \"Layer\" NOT LIKE 'BOUND-ADMIN-VIR%' "

Test it - and if your single quotes are also giving trouble (I don't think they will), then try this:
" \"Layer\" LIKE \'BOUND%\'  AND \"Layer\" NOT LIKE \'BOUND-ADMIN-VIR%\' "


..enjoy,
Wayne
0 Kudos
MathewCoyle
Frequent Contributor
You can eliminate the confusing escape characters by using string substitution and the AddFieldDelimiters function.

query =  "{0} LIKE 'BOUND%'  AND {0} NOT LIKE 'BOUND-ADMIN-VIR'".format(arcpy.AddFieldDelimiters(Polyline, 'Layer'))
arcpy.FeatureClassToFeatureClass_conversion(Polyline, Fea_Class_Path, "PCL_LN", query)


Also, I don't see your Polyline variable declared anywhere.
0 Kudos