I strongly dislike using try/except as a control-structure. I would prefer you to use built-in function which return True/False.

-Drew

On 2/23/11 6:07 PM, John Fischer wrote:
Drew,

Sue mentioned that as well. This will not catch the case where the clientdir
does not exist which will cause an exception.

I could:

    if not os.path.exists(path) or not os.path.isdir(path):
        continue

Then do the for loop which contains the os.listdir(path) call.

Do you still think that the os.path.isdir()/os.path.exists() is the better
route then the try/except?  If so then I'll make that change.

Thanks,

John

On 02/23/11 04:36 PM, Drew Fisher wrote:
John,

Why not use os.path.isdir(clientdir) which will not raise an exception?

If it's a file, it'll return False and you can continue to the next entry.

-Drew
_______________________________________________
caiman-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/caiman-discuss

Reply via email to