2 Answers
2

I tested your snippet (at least in ArcMap's interactive Python window) and got the same error until I changed the formatting of the string parameter to the Layer() method. Either single or double quotes work, but I had to use forward slashes, not backslashes, and no leading 'r'. Like:

thanks , but code not work for shp file for lyr it works and i used extra function of arcpy.MakeFeatureLayer_management to convert shp to lyr . now it works for me
–
Mak PakMar 30 '12 at 15:54

no, I know the API examples show use of *.lyr file, but what I show above most definitely works with a shapefile or other data source, I took your snippet exactly and only modified the string argument as shown and it ran successfully.
–
MC5Mar 30 '12 at 16:00

thanks anyway but not working for me, and i donot the reason
–
Mak PakMar 30 '12 at 16:29