GEOG 485:
GIS Programming and Software Development

Lesson 1 Practice Exercise 3 Solution



import arcpy

name = arcpy.GetParameterAsText(0)
print ("Hi, " + name)


There are other means of obtaining user input from the PythonWin IDE, but this course is focused on executing scripts from within ArcGIS, so the exercise asked you to use arcpy's GetParameterAsText method. That means that, unlike the first two exercises, this script requires importing arcpy. As mentioned, the script can be executed from within PythonWin by entering the name parameter in the Arguments box after clicking the Run button. GetParameterAsText is zero-based, so the script is set up to get parameter 0 (the first and only parameter).

Note that it would also be acceptable to do away with the name variable as follows:

print ("Hi, " + arcpy.GetParameterAsText(0))