1) Using the python sys library.
2) Using ESRI arcpy library.
grasslandSelect = sys.argv[1]
grasslandSelect = arcpy.GetParameter(0)
There are some obvious differences. Python uses the argv[0] to pass the argument of the actual python script, so the first argument entered in the command line is argv[1].
ESRI GetParameter(0) is the first parameter passed when calling the script from a Toolbox.
For the case of Boolean arguments, it is worth mentioning that sys.argv will return ,with a lower case, 'true' or 'false' while arcpy.GetParameter will return, with a capital, 'True' or 'False'. Though I had not problems complementing either(not True, not true), I did have some unidentified issues using the lower case 'true/false'
No comments:
Post a Comment