Wow – I saw this three line script at gis.stackexchange.com that will list all data in a File Geodatabase and was impressed! Three lines! A thing of beauty! When I looked closer, I saw a yield tool that I wasn’t familiar with, so I set about learning what the heck it is.
Here is a useful explanation: http://stackoverflow.com/questions/231767/the-python-yield-keyword-explained of what is going on.
def listFcsInGDB(): ''' set your arcpy.env.workspace to a gdb before calling ''' for fds in arcpy.ListDatasets('','feature') + ['']: for fc in arcpy.ListFeatureClasses('','',fds): yield os.path.join(arcpy.env.workspace, fds, fc)
Turns out, it’s like a list, but just feeds your script one item at a time. You can go ahead and generate giant lists and not worry about overloading what ever you are doing. It’s great for this kind of setting where you don’t know how much data is going to be listed.
I haven’t personally used this yet, but wow, I hope I get too because I’ll feel like I moved up a notch on the ladder of Python. Let me know if you have success!