Select to view content in your preferred language

Use of f-strings in GP Tools Share As WebTool

393
0
05-16-2024 01:34 AM
Status: Open
MarcHoogerwerf_EsriNL
Occasional Contributor

Enable the use of Python f-strings to assemble paths to data sources.

Currently if I use Python f-strings to assemble paths to data sources, the GP Tool runs fine, but when publishing this GP tool through Share as WebTool, the Analyze process will trow en error:

 

00068: Result <value> contains broken project data source: <value>

For example:

folder = "c:/temp"
fdgb = "test.gdb"
fc_name = "my_example"

ds = f"{folder}/{fgdb}/{fc_name}"
if arcpy.Exists(ds):
    arcpy.management.Delete(ds)

Currently, as suggested in Article ID: 000022882, a work-around could be to replace the / in the string literal with ? and then use .replace('?',"/)" to fool the Analyze process.

Instead of relying on this work-around,  it would be much cleaner to have the f-strings properly supported when using the Share As WebTool, as they are the preferred way of string formatting in current Python 3.x versions

Tags (2)