Improve ArcPy List Functions Documentation: Explain Wildcard Position

104
2
yesterday
Status: Open
AliTalaat22
New Contributor

The current ArcPy documentation for List functions (ListWorkspaces, ListFeatureClasses, etc.) only briefly mentions that the wildcard * represents “zero or more characters” and is case-insensitive. However, it does not explain how the position of the wildcard (start, end, or both) affects the results.

The example below demonstrates the difference between patterns '*.gdb', 'ALI_BIO*', and '*ALI*'. Adding such examples to the documentation would help users understand wildcard behavior and avoid confusion.

import arcpy

# Set the workspace
arcpy.env.workspace = r"C:\GIS\Projects"

# Example 1: Any item ending with .gdb
ending_gdb = arcpy.ListWorkspaces("*.gdb")
print("Pattern '*.gdb' matches:", ending_gdb)

# Example 2: Any item starting with ALI_BIO
starting_ref = arcpy.ListWorkspaces("ALI_BIO*")
print("Pattern 'ALI_BIO*' matches:", starting_ref)

# Example 3: Any item containing ALI anywhere
contains_tpt = arcpy.ListWorkspaces("*ALI*")
print("Pattern '*ALI*' matches:", contains_tpt)
 
Tags (1)
2 Comments
JoshuaBixby

@AliTalaat22 , wildcard behavior is fairly standard across programming/scripting languages and commands.  Is there specific wildcard behavior that you are finding unexpected?  If so, can you provide an example?

DanPatterson

many of the use cases are contained within the code samples, for example from

ListDatasets—ArcGIS Pro | Documentation

# Print all the feature datasets in the workspace that start with the letter c
# or f.
datasets1 = list(set(arcpy.ListDatasets("c*", "Feature")) |
                 set(arcpy.ListDatasets("f*", "Feature")))
print(datasets1)

or 

# Print all the feature datasets in the workspace that contain both the letter c
# and f.
datasets3 = list(set(arcpy.ListDatasets("*c*", "Feature")) &
                 set(arcpy.ListDatasets("*f*", "Feature")))
print(datasets3)

so yes, specific examples of unexpected behaviour would be useful