Skip to content

Commit 47a3425

Browse files
committed
content/scripts: whitespace cleanup
1 parent 13a4269 commit 47a3425

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

content/scripts.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ Command line arguments with ``sys.argv``
8888
We now have a python script that is callable from the command line (e.g. for use on an HPC system).
8989
However, this code is still not adjustable, as we still need to have a copy for each single
9090
time range we want to plot, or need to modify our file whenever we want to just change parameters.
91-
What we need is to allow arguments to be put in from the command line in order to have the same code
91+
What we need is to allow arguments to be put in from the command line in order to have the same code
9292
plot information for different time ranges without odifying the code itself. This can be achieved by
93-
using pythons :py:mod:`sys` package, which provides access to arguments given to the python interpreter at
93+
using pythons :py:mod:`sys` package, which provides access to arguments given to the python interpreter at
9494
startup in the :py:data:`sys.argv` list. The first (i.e. ``sys.argv[0]`` entry of this array is the called script,
9595
and any further argument (separated by space) is appended to this list. Lets see how it works:
9696

@@ -147,15 +147,15 @@ Parsing command line arguments with ``argparse``
147147
------------------------------------------------
148148

149149
:py:mod:`Argparse <argparse>` not only gives you descriptive command line arguments, it also automatically
150-
generates a ``--help`` option for you. To use ``argparse`` you first set up a parser
151-
by calling ``parser = argparse.ArgumentParser()`` and then you add arguments using
150+
generates a ``--help`` option for you. To use ``argparse`` you first set up a parser
151+
by calling ``parser = argparse.ArgumentParser()`` and then you add arguments using
152152
:py:meth:`parser.add_argument(args) <argparse.ArgumentParser.add_argument>`. There are two different types of arguments:
153153

154154
- Positional arguments
155155
- Optional arguments
156156

157157
Positional arguments are fixed in their position, while optional arguments need to be
158-
given with their respective flags ( like ``--name`` or ``-n``).
158+
given with their respective flags ( like ``--name`` or ``-n``).
159159
The following example would parse a positional argument ``Name`` of type ``string``
160160
and an optional argument ``date`` of type ``string`` which defaults to ``01/01/2000``.
161161

@@ -174,7 +174,7 @@ and an optional argument ``date`` of type ``string`` which defaults to ``01/01/2
174174
175175
print(args.Name + " was born on " + args.date)
176176
177-
If this code was in ``birthday.py`` and we would call ``python birthday.py --help`` it
177+
If this code was in ``birthday.py`` and we would call ``python birthday.py --help`` it
178178
would show the following message:
179179

180180
.. code-block:: console
@@ -195,7 +195,7 @@ Exercises 2
195195
.. challenge:: Scripts-2
196196

197197
1. Take the python script we have written in the preceding exercise and use
198-
:py:mod:`argparse` to specify the input and output files and allow the start and end dates to be set.
198+
:py:mod:`argparse` to specify the input and output files and allow the start and end dates to be set.
199199
The start and end dates should be optional parameters with the defaults as they are in the current script.
200200

201201
2. Execute your script for a few different time intervals (e.g. from January 2019 to June 2020, or from Mai 2020 to October 2020).

0 commit comments

Comments
 (0)