Summary
Returns a list of versions that the connected user has permission to use.
Discussion
Specify the path to a connection file as an argument to the function, or set the workspace environment to the connection file and call the ListVersions function without arguments.
Note:
The arcpy.ListVersions function is different from the arcpy.da.ListVersions function, which returns a list of Version objects.
Syntax
ListVersions (sde_workspace)
Parameter | Explanation | Data Type |
sde_workspace | An enterprise geodatabase workspace. | String |
Data Type | Explanation |
String | A list of version names in the enterprise geodatabase that the connected user has permissions to use. |
Code sample
Get the list of versions the user has permissions to use and print them.
import arcpy
database = "Database Connections/toolboxDEFAULTVersion.sde"
versions = arcpy.ListVersions(database)
# Print the versions available to the user
for version in versions:
print(version)