You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _episodes/07-command_line.md
+15-2
Original file line number
Diff line number
Diff line change
@@ -483,8 +483,17 @@ if __name__ == "__main__":
483
483
>> {: .language-python}
484
484
>>
485
485
> {: .solution}
486
+
>
486
487
>> ## Solution - Mac and Linux
487
-
>> For this solution, you would have to find the option `nargs` which would be added to `add_argument` which tells argparse that it may receive more than one value for the argument. T
488
+
>> This solution will work for Mac and Linux operating systems. For this solution, you would use the script without the quotes (below).
489
+
>> Note that the solution given above will work for any operating system.
490
+
>>
491
+
>> ~~~
492
+
>> $ python analyze_mdout.py data/*.mdout
493
+
>> ~~~
494
+
>> {: .language-bash}
495
+
>>
496
+
>> For this solution, you would have to find the option `nargs` which would be added to `add_argument` which tells argparse that it may receive more than one value for the argument. This works on Mac and Linux because these operating systems will automatically create a list of files when you use the wildcard character (`*`).
488
497
>>
489
498
>> ~~~
490
499
>> import os
@@ -498,6 +507,7 @@ if __name__ == "__main__":
498
507
>>
499
508
>> args = parser.parse_args()
500
509
>>
510
+
>> # This will already be a list, so we don't need to use glob.
501
511
>> filenames = args.path
502
512
>>
503
513
>> for filename in filenames:
@@ -548,17 +558,20 @@ if __name__ == "__main__":
548
558
>> ~~~
549
559
>> import os
550
560
>> import argparse
561
+
>> import glob
551
562
>>
552
563
>> # Get filename from argparse
553
564
>>
554
565
>> parser = argparse.ArgumentParser("This script parses amber mdout file to extract the total energy.")
555
566
>>
556
567
>> parser.add_argument("path", help="The filepath of the file to be analyzed.", nargs='*')
568
+
>>
569
+
>> # store_true makes this True by default
557
570
>> parser.add_argument("-make_plots", help="Flag to create plots", action='store_true')
0 commit comments