Example:
# Describe feature class
#
desc = arcpy.Describe(fc)
# Get Fields
#
fields = desc.fields
for field in fields:
# do something with the field
print field. name
The properties of the field and index object are below:
Enjoy
# Describe feature class
#
desc = arcpy.Describe(fc)
# Get Fields
#
fields = desc.fields
for field in fields:
# do something with the field
print field. name
>>> import arcpy
>>> arcpy.GetCount_management("c:/temp/streams.shp")
>>> arcpy.GetCount_management("c:\\temp\\streams.shp")
>>> arcpy.GetCount_management(r"c:\temp\streams.shp")
>>> arcpy.GetCount_management("c:\temp\streams.shp")
# ExecuteError: Failed to execute. Parameters are not valid.
# ERROR 000732: Input Rows: Dataset c: em\streams.shp does not exist or is not supported
# Failed to execute (GetCount)
import arcpy
from arcpy import env
# Set the workspace. List all of the feature classes that start with 'G'
#
env.workspace = r"c:\temp\data.gdb"
fcs = arcpy.ListFeatureClasses("G*")
# Set the workspace. List all of the TIFF files
#
env.workspace= r"c:\temp\images"
# Gets a list of raster data (TIF)
#
for tiff in arcpy.ListRasters("*", "TIF"):
print tiff
"When a script is run inside a tool from an ArcGIS application or from another geoprocessing script, the environment settings used by the calling application or script are passed to it. These settings become the default settings used by the tool's script when it is executed. The called script may alter the settings passed to it, but those changes are only used within that script or by any other tool it may call."The environmental settings are exposed as properties on the env class. These properties can be used to retrieve the default values and to set custom values.
>>> import arcpy
>>> from arcpy import env
>>> env.workspace = "c:/data"
>>> import arcpy
>>> print arcpy.ListEnvironments()
>>> # Load settings
>>> arcpy.LoadSettings(file)
>>> # Save Settings
>>> arcpy.SaveSettings(saveFile)
>>> arcpy.ImportToolbox(".tbx")
# Run the imported tool
#
>>> arcpy.toolname_alias(parameters)
>>> arcpy.ImportToolbox("http://server/arcgis/services;BufferByVal")
import arcpy
from arcpy import sa
from arcpy import ga
from arcpy import mapping