The Hamma Posted March 29, 2022 Share Posted March 29, 2022 (edited) Adding this to your script will display the time it took to run. import time startTime = time.time() #your code here executionTime = (time.time() - startTime) vs.AlrtDialog('Execution time in seconds: ' + str(executionTime)) Use this to use a list to elimimate options from another list OmitList =['name1','name2','name3', 'name4','name5'] #replace name# with names of items to skip for List2 in reversed(range(1,List2+1)): #List2 is the list of items you wish to process. Remove Reversed() to step through list in order. if any(item == vs.GetName(List2) for item in OmitList): #if name of List2 item matches name in OmitList it will result in True continue #skip rest of script for this item and continue to next item in List2 #Insert script to execute if name is not in OmitList. Edited April 11, 2022 by The Hamma 2 Quote Link to comment
Juliensv Posted February 24, 2023 Share Posted February 24, 2023 For the second one, you're not making use of the crazy features built into Python to write really compact code! Namely, you can use a list comprehension to get just your second list without the omitted items, or you can just simply use the "in" test while looping through the items in your second list! omitList =['name2', 'name3', 'name4'] listToFilter = ['name1', 'name2', 'name3', 'name4', 'name5'] #either use a list comprehension to get the filtered list filteredList = [name for name in listToFilter if name not in omitList] # or step through the list and use "in" to test each name for name in listToFilter: if name in omitList: continue #rest of your function 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.