I have the following function:
def filterArgs( args ):
filterflag = len(args)>=1 and args[0] == "-i"
if flag:
args = " ".join(args[1:]).strip()
else:
args = " ".join(args).strip()
In my code I call it like this:
filterArgs( [ 106645929 ] ) #example 1
filterArgs( [ "-i", 106645929 ] ) #example 2
Is there a way to use something like a conditional operator in C and ignore the func filterArgs?
args = filterflag ? args[1:] : args
My objective is to write less lines.
in python, C’s
cond ? iftrue : iffalsetranslates toiftrue if cond else iffalsethus,
args = args[1:] if filterflag else args