-
-
Save marceloneppel/377c4e18d617bc4652aa4c3efb2fbcde to your computer and use it in GitHub Desktop.
Using PyXA to get the number of shortcuts in each shortcuts folder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tested with PyXA 0.1.0 | |
import PyXA | |
app = PyXA.Application("Shortcuts") | |
folders = app.folders() | |
# Method 1 - Standard iteration | |
summary = [] | |
for folder in folders: | |
folder_name = folder.name | |
num_shortcuts = len(folder.shortcuts()) | |
summary.append((folder_name, num_shortcuts)) | |
print("Method 1:", summary) | |
# Method 2 - Use bulk methods | |
shortcuts_by_folder = zip(folders.name(), folders.shortcuts()) | |
summary = [(name, len(shortcuts)) for name, shortcuts in shortcuts_by_folder] | |
print("Method 2:", summary) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment