This repository has been archived by the owner on Oct 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 112
Argument Parsing 1/3 #140
Labels
Comments
twemyss
added a commit
to twemyss/rse-classwork-2020
that referenced
this issue
Nov 26, 2020
Closed
Open
umitozmen
added a commit
to umitozmen/rse-classwork-2020
that referenced
this issue
Nov 26, 2020
Closed
Closed
Open
DavidScobie
added a commit
to DavidScobie/rse-classwork-2020
that referenced
this issue
Nov 26, 2020
Open
esl-lewis
added a commit
to esl-lewis/rse-classwork-2020
that referenced
this issue
Nov 26, 2020
dpshelio
added a commit
that referenced
this issue
Nov 27, 2020
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When writing code, it is important to think about how you or others can run it. A popular way is to use a command-line interface, so that your code can be executed as a script from a terminal. In this exercise we will look at the tools that Python offers for creating such interfaces.
We will use the
squares.py
file we used last week for the documentation exercise. We will make the code more generic by creating a command-line interface that will make it easier to call.Constant weight
Let's first make our first interface without weights (assuming them constant and equal to 1).
week06
branch.squares.py
. Make sure you can run it from a terminal!if __name__ == "__main__":
guard. This is the code that you will work on. Currently, the input values are hardcoded into the file.argparse
library to rewrite this part so that it reads only thenumbers
from the command-line (keep for now the weights hardcoded). The file should be runnable aspython squares.py <numbers>...
(where<numbers>
should be replaced by the sequence of numbers of your choice)argparser
arguments.python squares.py --help
.Addresses #140
in the pull request description), remember to mention your team members too! (with@github_username
)The text was updated successfully, but these errors were encountered: