I am not getting any response from this script and no error displayed at all

I am writing this script to help me display the feature classes in my geodatabase

Here is my script

import arcpy
arcpy.env.workspace = r"Q:\basemaps\ALTA\FileGeodatabase\AB_IHS_GIS_DATA.gdb"
logfile = open(r"C:\tmp\log.txt ","w")
fcLst = arcpy.ListFeatureClasses()
for fc in fcLst:
     logfile.write(fc + "\n")

1 Answer 1


Make sure the directory C:\tmp exists. If it does not, your third call will fail. I normally use unicode and double slashes for my workspaces.


But the big problem is that your logfile.close() is inside your for loop. That needs to be outside the for loop, or else you will close the logfile after the first featureclass name is written. You also have a typo in your variable assignment for fcLst.

import arcpy, os
arcpy.env.workspace = u"J:\\restored-20101025\\basemaps\\ALTA\\FileGeodatabase\\GEOBASE_GIS_DATA.gdb"
if os.path.exists(arcpy.env.workspace):
    if not os.path.isdir(r"C:\tmp"):
    logfile = open(r"C:\tmp\log.txt", "w")
    fcList = arcpy.ListFeatureClasses()
    dsList = arcpy.ListDatasets()
    for fc in fcList:
    for ds in dsList:
        fcList = arcpy.ListFeatureClasses("","All",ds)
        for fc in fcList:
    print("Workspace does not exist.")
  • yes the temp folder does exist and i tried re-writing the code again and now i dont get any error at but it does not display the feature classes
    – Shade
    Commented Aug 3, 2012 at 16:18
  • Just added a code sample Commented Aug 3, 2012 at 16:22
  • I got the problem sorted out. The feature classed were in another subfolder inside the geodatabase. my code is right so what happens is that when i run the script it list the feature classes inside the tmp folder in my c drive as specified
    – Shade
    Commented Aug 3, 2012 at 16:28
  • Sounds like they were in a feature dataset. I modified the script again to deal with those too. The one feature class this script will not get to is a feature class inside a feature type inside a feature dataset, e.g. the feature classes inside a parcel fabric inside a feature dataset. Commented Aug 3, 2012 at 17:17
  • 2
    Hi @Shade, if you found blord-castillo's answer helpful, would you mind "accepting" it? There's a checkbox beneath the voting buttons. It's a small thing, but it's part the currency that drives stack exchange. You might find that people are less willing to help you if you don't participate.
    – canisrufus
    Commented Aug 3, 2012 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.