Python gp.ListFeatureClasses return only one file

Andreas Perstinger andreas.perstinger at gmx.net
Thu Oct 13 09:49:23 EDT 2011


On 2011-10-13 14:00, yo wrote:
> Hi All,
> I m using the gp.ListFeatureClasses to make a list of file in my
> directory (containing several hundreds of file)
> however when I print the variable in which the List is supposed to be
> stored, the print just return one file name....
> does any one have an idea????

Depending on the version you are using, "ListFeatureClasses()" returns 
either a list or an enumeration object:
http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=ListFeatureClasses_method

You are just printing the first item. To print all, something like the 
following should work (assuming you are using version 9.2):

shpList = gp.ListFeatureClasses("*.shp")
shp = shpList.Next()
while shp:
     print shp
     shp = shpList.Next()

Bye, Andreas



More information about the Python-list mailing list