Skip to content

Instantly share code, notes, and snippets.

@M-Bryant
Created August 19, 2015 01:09
Show Gist options
  • Save M-Bryant/8fe126b4be8a8a195e06 to your computer and use it in GitHub Desktop.
Save M-Bryant/8fe126b4be8a8a195e06 to your computer and use it in GitHub Desktop.
arcpy: get workspace from feature class, without arpy
import os
def get_workspace(in_feature_class):
''' Get the workspace for a feature class'''
workspace = os.path.dirname(in_feature_class)
if [any(ext) for ext in ('.sde', '.gdb', '.mdb') if ext in os.path.splitext(workspace)]:
return workspace
else:
return os.path.dirname(workspace)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment