[Tutor] How to insert a variable into a pathname?
Kent Johnson
kent37 at tds.net
Tue Nov 9 18:12:38 CET 2004
Patrick Thorstenson wrote:
> The variable “VAR_Archive” is a 4 digit non-integer string such as 5355
> or 5079. I want to insert it into both the input and output sides of the
> command.
>
> I want the final result to be:
>
> Testfile = “F:/Parcels/Parcelshapefiles/p5355_test.shp”
>
> Archive = “F:/Parcels/Aparcelarchives/p5355Archive.shp”
> ###
>
> testfile = "F:/Parcels/ParcelShapefiles/p%s_test.shp"
>
> testfile % (VAR_Archive)
This creates a NEW string with the value you want, but doesn't do
anything with it. You need to assign it back to testfile:
testfile = testfile % (VAR_Archive)
> archfile = "F:/Parcels/Aparcelupdate/p%sArchive.shp"
>
> archfile % (VAR_Archive)
Likewise here
archfile = archfile % (VAR_Archive)
Kent
More information about the Tutor
mailing list