I am trying to get a search cursor to go through each row and Multi buffer a feature.

I keep getting a syntax error with no error codeother than Invalid Syntax (traceback to this line of code) so i am assuming its something I am doing in the calling of the multiring buffer.

Error Message:

C:\Python27\ArcGIS10.3\python.exe N:\GIS\Projects\AA_Leith_Hawkins_TestBed\Search_Cursor\Script\SearchCUrsor.py
File "N:\GIS\Projects\AA_Leith_Hawkins_TestBed\Search_Cursor\Script\SearchCUrsor.py", line 19
arcpy.MultipleRingBuffer_analysis('Holdings_Layer', 'ofc', distances, unit, "", "ALL")
SyntaxError: invalid syntax

Code below

import arcpy
from arcpy import env
arcpy.env.overwriteOutput = True

file_workspace = "r'N:\GIS\Projects\AA_Leith_Hawkins_TestBed\Search_Cursor\Search_Cursor.gdb"
env.workspace = file_workspace
Var_Polygonname = row[0]
Holdings = r'N:\GIS\Projects\AA_Leith_Hawkins_TestBed\Search_Cursor\Search_Cursor.gdb\Data\Holdings'
ofc = r'N:\GIS\Projects\AA_Leith_Hawkins_TestBed\Search_Cursor\Search_Cursor.gdb'
distances = [1000, 4000]
unit = "Meters"

with arcpy.da.SearchCursor(Holdings, ['Holding_Reference_Number'])as Holdings_Ref_cursor:
for x in Holdings_Ref_cursor:
    print x[0] + Var_Polygonname

    arcpy.SelectLayerByAttribute_management('Holdings_Layer', 'NEW_SELECTION', '"Holding_Reference_Number" = \'Var_Polygonname\''
    arcpy.MultipleRingBuffer_analysis('Holdings_Layer', 'ofc', distances, unit, "", "ALL")
   #arcpy.Buffer_analysis("Holdings_Layer", ofc, var_Buffer, "FULL", "ROUND", "ALL", "")
    print'Buffer complete'
  • 3
    Missing right paren on the line above.
    – Vince
    Commented Feb 3, 2017 at 0:28

1 Answer 1


On the first line below (as @Vince commented) there is a missing right parenthesis at the end of the line. The error message appears to be telling you that there is a problem on the arcpy.MultipleRingBuffer_analysis() line but because the previous line is unfinished it is really saying "on this line or the line before that I think is part of it".

Instead of:

arcpy.SelectLayerByAttribute_management('Holdings_Layer', 'NEW_SELECTION', '"Holding_Reference_Number" = \'Var_Polygonname\''
arcpy.MultipleRingBuffer_analysis('Holdings_Layer', 'ofc', distances, unit, "", "ALL")

try this:

arcpy.SelectLayerByAttribute_management('Holdings_Layer', 'NEW_SELECTION', '"Holding_Reference_Number" = \'Var_Polygonname\'')
arcpy.MultipleRingBuffer_analysis('Holdings_Layer', 'ofc', distances, unit, "", "ALL")
  • Parens are not required on print statements (it's not a function). They're not required on if either, but I prefer to write my code that way.
    – Vince
    Commented Feb 3, 2017 at 0:38
  • @Vince I removed the part about the print statement because to my surprise print'x' works just as well as print('x') and print 'x' at Python 2.x. However, for Python 3.x which I'm trying to ready ArcPy users for wherever possible, print'x' => SyntaxError: invalid syntax, print 'x' => SyntaxError: Missing parentheses in call to 'print', and only print('x') actually prints x (and also works at 2.x).
    – PolyGeo
    Commented Feb 3, 2017 at 0:50
  • Yowza! That's gonna be a painful porting experience.
    – Vince
    Commented Feb 3, 2017 at 1:00
  • That has been the hardest thing for me, both in porting and in just typing raw code - including the parentheses on a print statement
    – Midavalo
    Commented Feb 3, 2017 at 1:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.