How to get all field names from table using arcpy.ListFields?
Yes. The return
statement short-circuits it. Basic Python.
def a(path):
field_names = []
fields = arcpy.ListFields(path,"FID_*")
for field in fields:
field_names.append(field.name)
return field_names
Though you may need to do it this way:
def a(path):
field_names = []
fields = arcpy.ListFields(path,"FID_*")
for field in fields:
field_names.append(field.name)
return ";".join(field_names)
def getFieldNames(shp):
fieldnames = [f.name for f in arcpy.ListFields(shp)]
return fieldnames
fieldnames = getFieldNames("country.shp")
returns a list of all fields of country.shp