Hi,
I couldn't figure out why arcpy.ListFeatureClasses() doesn't work when I set env.workspace = os.path.join (path,gdb)
and works when I set env.workspace = r"path to the gdb"!
here is an example:
The below script works in my IDE
import arcpy
gdbANDpath=r"C:\ahmad data\data\MyProject5\f.gdb"
arcpy.env.workspace=gdbANDpath
fclist=arcpy.ListFeatureClasses()
print len(fclist)
prints >> 8
while the following script doesn't work and gives an error:
import arcpy
import os
gdb_name="f.gdb"
gbd_path="C:\ahmad data\data\MyProject5"
gdbANDpath=os.path.join(gdb_name,gbd_path)
arcpy.env.workspace=gdbANDpath
fclist=arcpy.ListFeatureClasses()
print len(fclist)
Traceback (most recent call last):
File "<module1>", line 31, in <module>
TypeError: object of type 'NoneType' has no len()
>>>
fclist here returns none and fails to create a list of feature classes in the gdb!
PS: Tested on ArcMap 10.7.1 and 10.6.1, on more than one gdb