Timeline for Passing Python List into Layer Definition Query
Current License: CC BY-SA 3.0
5 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 23, 2012 at 15:54 | comment | added | Mike | Oh, I think you have to just reverse the quotes when formatting (i.e. distList.append("'{}'".format(row.Field1)), double quotes on the outside of {} and single quotes on the inside) | |
Aug 23, 2012 at 15:32 | comment | added | Mike | Oh, I just discovered after running my script a few times, that this approach almost solves my problem, but one last issue is, it wraps each items in the list in double quotes instead of single quotes. (i.e. "SMU" in ("O1", "S2", "O20", "O23a") whereas the definition query on likes the items to be wrapped in single quotes ("SMU" in ('O1', 'S2', 'O20', 'O23a'). I need to find a way to replace those double quotes. | |
Aug 22, 2012 at 21:36 | vote | accept | Mike | ||
Aug 22, 2012 at 21:35 | comment | added | Mike | Thanks Jason. This worked perfectly. For added value, I threw in the 'set' function to eliminate duplicates which occur in my case: lyr.definitionQuery = '"Field1" in ({})'.format(", ".join(set(distList))) | |
Aug 22, 2012 at 20:52 | history | answered | Jason Scheirer | CC BY-SA 3.0 |