This should be extremely easy but I've now been at it an hour with no end in site. I'm using the simplekml module in python and I want to create a folder if one doesn't exists. I can't find anyway to check if a folder exists already without creating a for loop. I would think the below would work but of course it doesn't.
kml = simplekml.Kml()
testfold = kml.newfolder(name = 'testfolder')
testfold2 = kml.newfolder(name = 'testfolder2')
if 'testfolder' in kml.containers:
print True
The only thing that seems to return the fold names is:
for x in kml.containers:
print x.name
But of course I would prefer not to iterate through every container in the kml file looking for a folder before then writing it if it isn't found. Please tell me there's a better way?!