IsBeingEdited

Resumen

Determines whether the given dataset or workspace is in an edit session.

Debate

The IsBeingEdited method can be used to check if a data source is currently in an edit session. This is similar to the isEditing property on the Editor class but does not require you to create the Editor object. This can be useful to use on data sources in which multiple users or automated scripts are trying to perform edits at the same time.

Sintaxis

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

The input dataset or workspace to be checked for an ongoing edit session.

String
Valor de retorno
Tipo de datosExplicación
Boolean

True if the input dataset or workspace is in an edit session.

Muestra de código

IsBeingEdited example 1

The following code checks if the workspace is already in an edit session before starting a new one.

import arcpy

arcpy.env.workspace = r"C:\data\myGDB.gdb"

if not arcpy.IsBeingEdited(arcpy.env.workspace):
    edit = arcpy.da.Editor(arcpy.env.workspace)
    edit.startEditing()
IsBeingEdited example 2

The following code lists the name of any feature layers in a map that have pending edits.

import arcpy

aprx = arcpy.mp.ArcGISProject("CURRENT")
map = aprx.listMaps()[0]

for lyr in map.listLayers():
    if lyr.isFeatureLayer and arcpy.IsBeingEdited(lyr):
        print(lyr.name)