newbie - variable "buried in quotes"
Peter Hansen
peter at engcorp.com
Mon May 16 12:59:12 EDT 2005
Peter Hansen wrote:
> The % operator goes immediately after the string on which it operates:
>
> gp.FeatureclassToCoverage_conversion("'Database
> Connections\\%s at GIS_srv-earth.sde\\GIS.GIS.Cadastral\\GIS.GIS.Parcels'
> POLYGON" % luser, prcl83, "", "DOUBLE")
Missed your buried question about line continuations. Yes, there is
one, and it's the conventional \ at the end of the line.
On the other hand, there are better approaches:
gp.FeatureclassToCoverage_conversion("'Database Connections"
"\\%s at GIS_srv-earth.sde\\GIS.GIS.Cadastral\\GIS.GIS.Parcels'"
"POLYGON" % luser, prcl83, "", "DOUBLE")
That, for example, uses the fact that adjacent strings are combined into
one by the parser. Since they are all enclosed in parentheses, they are
considered "adjacent" even though they come on different lines without
line continuation characters.
It's pretty rare to need to use \ to continue lines, unless it's just a
style you don't mind or prefer.
(Personally, I'd write this differently. Create a variable called path
or something just above that line, doing the string substitution when
you build it. Then the call to FeatureclassToCoverage_conversion() can
come all on one line using "path", even with its unwieldy name. :-)
-Peter
More information about the Python-list
mailing list