Trying to use rstrip

Discussion created by monzay on Aug 20, 2013
Latest reply on Aug 20, 2013 by Caleb1987
I want to strip off the last 4 characters of a layer name that is in my mxd. It is the only layer. It is a MrSid file. I want to
export this image to pdf using the layer name without the .sid part. This code exports the map to PDF but it is not stripping off the .sid part. Ex: J-228-01-W-2013.sid.pdf

I used 4 as the number of characters to strip off because I assumed that the dot needs to be removed also.

import arcpy,os

mxd = arcpy.mapping.MapDocument(r"C:\GIS\designsheet.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
df.rotation = 0
lname = arcpy.mapping.ListLayers(mxd)[0].name
outFile = r"C:\GIS\output\\" + lname.rstrip('4') + ".pdf" 
arcpy.mapping.ExportToPDF(mxd, outFile)

- Mike