I have a tuple of unknown elements, which I want to convert into a string for using in the arpy command

arcpy.Merge_management([Input1, Input2, ..., Inputx], "D:\\test.shp")

In my example I have only three elements in the tuple and tried to convert this element into one string as the inputs for the command. I do this with following command:

Input = "['" + "', '". join((str(n) for n in args)) + "']"

If I display the variable [Input], I get a plausible result.

['D:\\Buildings\\Gemeinden\8537\8537_Change_Detection_TLM_LAZ_pre.shp', 'D:\\Buildings\\Gemeinden\8537\8537_Change_Detection_TLM_AVS_pre.shp', 'D:\\Buildings\\Gemeinden\8537\8537_Change_Detection_TLM_DEM_pre.shp']

Unfortunately I got always following error message, when I tried to integrate the variable into the Merge command:

arcpy.Merge_management(Input, "D:\\test.shp")

ERROR 000732: Input Datasets: Dataset '['D:\\Buildings\\Gemeinden\8537\8537_Change_Detection_TLM_LAZ_pre.shp', 'D:\\Buildings\\Gemeinden\8537\8537_Change_Detection_TLM_AVS_pre.shp', 'D:\\Buildings\\Gemeinden\8537\8537_Change_Detection_TLM_DEM_pre.shp']' does not exist or is not supported

Can anyone help to solve the hopefully small problem?

2 Answers 2


Just glancing at this, it looks like you have escaped only half of your backslashes?


I would suggest trying a real string, escaping all the back slashes, or using forward slashes.

reference: https://pro.arcgis.com/en/pro-app/arcpy/get-started/setting-paths-to-data.htm


There's no need to convert to a string, you can directly supply a tuple or list as the argument.

From the examples:

import arcpy
arcpy.env.workspace = "C:/data"
arcpy.Merge_management(["majorrds.shp", "Habitat_Analysis.gdb/futrds"], "C:/output/Output.gdb/allroads")

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.