@@ -949,6 +949,30 @@ while True:
949
949
```
950
950
951
951
952
+ Command Line Arguments
953
+ ----------------------
954
+ ``` python
955
+ import sys
956
+ script_name = sys.argv[0 ]
957
+ arguments = sys.argv[1 :]
958
+ ```
959
+
960
+ ### Argparse
961
+ ``` python
962
+ from argparse import ArgumentParser, FileType
963
+ p = ArgumentParser(description = < str > )
964
+ p.add_argument(' -<short_name>' , ' --<name>' , action = ' store_true' ) # Flag
965
+ p.add_argument(' -<short_name>' , ' --<name>' , type = < type > ) # Option
966
+ p.add_argument(' <name>' , type = < type > , nargs = 1 ) # Argument
967
+ p.add_argument(' <name>' , type = < type > , nargs = ' +' ) # Arguments
968
+ args = p.parse_args()
969
+ value = args.< name>
970
+ ```
971
+
972
+ * ** Use ` 'help=<str>' ` for argument description.**
973
+ * ** Use ` 'type=FileType(<mode>)' ` for files.**
974
+
975
+
952
976
Open
953
977
----
954
978
** Opens file and returns a corresponding file object.**
@@ -1036,30 +1060,6 @@ cwd = Path()
1036
1060
```
1037
1061
1038
1062
1039
- Command Line Arguments
1040
- ----------------------
1041
- ``` python
1042
- import sys
1043
- script_name = sys.argv[0 ]
1044
- arguments = sys.argv[1 :]
1045
- ```
1046
-
1047
- ### Argparse
1048
- ``` python
1049
- from argparse import ArgumentParser, FileType
1050
- p = ArgumentParser(description = < str > )
1051
- p.add_argument(' -<short_name>' , ' --<name>' , action = ' store_true' ) # Flag
1052
- p.add_argument(' -<short_name>' , ' --<name>' , type = < type > ) # Option
1053
- p.add_argument(' <name>' , type = < type > , nargs = 1 ) # Argument
1054
- p.add_argument(' <name>' , type = < type > , nargs = ' +' ) # Arguments
1055
- args = p.parse_args()
1056
- value = args.< name>
1057
- ```
1058
-
1059
- * ** Use ` 'help=<str>' ` for argument description.**
1060
- * ** Use ` 'type=FileType(<mode>)' ` for files.**
1061
-
1062
-
1063
1063
Command Execution
1064
1064
-----------------
1065
1065
``` python
0 commit comments