I'm using list comprehension to find specific datasets within a PyTable. However when trying to combine with arguments from argparser it returns no values.
Here is the section of code:
if args.Scount:
print args.Scount, args.Scount[0], args.Scount[1]
print
print [row['GRBname'] for row in table.iterrows() if args.Scount[0] <= row['SCounts'] <= args.Scount[1]]
print
print [row['GRBname'] for row in table.iterrows() if 0 <= row['SCounts'] <= 10]
Where args.Scount
comes from:
parser.add_argument("--Scount", nargs=2, help="Used to display GRBs within the specified spectral count range")
So for example if I give --Scount 0 and 10:
First line prints ['0', '10'] 0 10
(this was just a test to check args had a value)
Second line prints []
Third line prints a list containing the selected row['GRBname']
within the row['Scount']
condition.
If I switch back to standard loop structure I get the same results, though searching through pytable, argparse and list comprehension documentation hasn't helped me on this specific problem.