I have created a piece of python code; however, I want to execute it from the command line with some arguments and options. What I have so far works ok (with the exception that i CANNOT enter in negative values for the arguments -- and i need to be able to!) How can i better write this code?
What i enter on the command line:
C:\...>mycode.p y arg1 arg2 arg3 -o filename -p filename -q filename (this is 3 arguments...
User Profile
Collapse
-
What is the fastest way to replace elements in list?
I am working with very large lists. I wish to replace elements satisfying a rule as quickly as possible.
For Example:
rule: if x < 0, replace with 0
Mylist: [1, 2, -4, -3, 4, -9]
Newlist: [1, 2, 0, 0, 4, 0]
I have Mylist and want to get Newlist. My best guess is to use enumerate, but not sure how to write this appropriately. Thanks -
Determine multiple indices within a list
I am trying to return a list of indices for elements within another list that pass some sort of rule (as fast as possible). Currently I am doing:
Elementspassed=[elem for elem in Mylist if point > elem]
for x in Elements passed:
newlist.append( Mylist.index(x) )
Mylist[Mylist.index(x)]=[]
I want to incorporate the for loop into the previous line. I am working with extremely large...
No activity results to display
Show More