Exists

Resumen

Determines the existence of the specified data object. This function tests for the existence of various data types including feature classes, tables, datasets, shapefiles, workspaces, layers, and files. The function returns a Boolean indicating whether the element exists.

Debate

Layers in a stand-alone script and layers in an active map can be used as input to Exists.

Sintaxis

Exists (dataset)
ParámetroExplicaciónTipo de datos
dataset

The path to the dataset to be checked for existence.

String
Valor de retorno
Tipo de datosExplicación
Boolean

A Boolean value of True will be returned if the specified element exists.

Muestra de código

Exists example

Check for the existence of specified data object.

import arcpy

# Set the current workspace
arcpy.env.workspace = "c:/base/data.gdb"

# Check for existence of data before deleting
if arcpy.Exists("roadbuffer"):
    arcpy.Delete_management("roadbuffer")

Temas relacionados