I've been trying to modify a function and every attempt seem to screw up the plist.
def removeItem(pl, item_name): for dock_item in pl['persistent-apps']: if dock_item['tile-data']['file-label'] == item_name: verboseOutput('found', item_name) pl['persistent-apps'].remove(dock_item) return True for dock_item in pl['persistent-others']: if dock_item['tile-data']['file-label'] == item_name: verboseOutput('found', item_name) pl['persistent-others'].remove(dock_item) return True return False
This scans through a dictionary array and looks for a match to a label name. If found it deletes the array element. I need to change this so I can supply an index and it will delete that element. I'm a total noob in python and I can't seen to find the right solution in the web docs I've read. My attempted solutions also added an additional parameter for 'persistent-apps' or 'persistent-others', so the above function is reduced to a single for loop. I'm actually trying to do this without the for loop at all. Can someone show me how to specify dock_item as it's position in the array?
This is how I plan to call the function;
def removeIndexItem(pl, pl_part, item_index):
Thanks in advance...
Edited 6 Years Ago by slingblade: n/a