Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Proper syntac to write string to config.py

$
0
0
Hello,

I am trying to write variable values to a config.py file so that I access the values from other scripts. I am having problems properly saving an SQL query statement to the config.py file.

Sample of my code:

sqlSel = arcpy.GetParameterAsText(1) (e.g. sqlSel will have the value "CNTYNAME" = 'ALACHUA'

fo.write("sqlSel = \"" + sqlSel + '''\"''' + "\n") (I have tried variations of this syntax with no luck -
fo.write("sqlSel = \"” + sqlSel + "\”\n")

What is written to the config.py file; Attachment 23615
sqlSel = ""CNTYNAME" = 'ALACHUA'" (CNTYNAME is not green indicating it is part of the string value)
Attached Thumbnails
Click image for larger version

Name:	results_py.PNG‎
Views:	N/A
Size:	1.2 KB
ID:	23615  

Viewing all articles
Browse latest Browse all 2485

Trending Articles