Skip to content

Commit

Permalink
Use variable for python
Browse files Browse the repository at this point in the history
Fix #129.

Propagate changes through the rest of the lesson.
  • Loading branch information
gcapes committed May 17, 2018
1 parent dfb3e42 commit b140373
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 22 deletions.
5 changes: 3 additions & 2 deletions code/06-variables-challenge/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
LANGUAGE=python
COUNT_SRC=wordcount.py
COUNT_EXE=python $(COUNT_SRC)
COUNT_EXE=$(LANGUAGE) $(COUNT_SRC)
ZIPF_SRC=zipf_test.py
ZIPF_EXE=python $(ZIPF_SRC)
ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC)

# Generate summary table.
results.txt : $(ZIPF_SRC) isles.dat abyss.dat last.dat
Expand Down
5 changes: 3 additions & 2 deletions code/06-variables/config.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Count words script.
LANGUAGE=python
COUNT_SRC=wordcount.py
COUNT_EXE=python $(COUNT_SRC)
COUNT_EXE=$(LANGUAGE) $(COUNT_SRC)

# Test Zipf's rule
ZIPF_SRC=zipf_test.py
ZIPF_EXE=python $(ZIPF_SRC)
ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC)
5 changes: 3 additions & 2 deletions code/07-functions/config.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Count words script.
LANGUAGE=python
COUNT_SRC=wordcount.py
COUNT_EXE=python $(COUNT_SRC)
COUNT_EXE=$(LANGUAGE) $(COUNT_SRC)

# Test Zipf's rule
ZIPF_SRC=zipf_test.py
ZIPF_EXE=python $(ZIPF_SRC)
ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC)
5 changes: 3 additions & 2 deletions code/08-self-doc/config.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Count words script.
LANGUAGE=python
COUNT_SRC=wordcount.py
COUNT_EXE=python $(COUNT_SRC)
COUNT_EXE=$(LANGUAGE) $(COUNT_SRC)

# Test Zipf's rule
ZIPF_SRC=zipf_test.py
ZIPF_EXE=python $(ZIPF_SRC)
ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC)
7 changes: 4 additions & 3 deletions code/09-conclusion-challenge-1/config.mk
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Count words script.
LANGUAGE=python
COUNT_SRC=wordcount.py
COUNT_EXE=python $(COUNT_SRC)
COUNT_EXE=$(LANGUAGE) $(COUNT_SRC)

# Plot word counts script.
PLOT_SRC=plotcount.py
PLOT_EXE=python $(PLOT_SRC)
PLOT_EXE=$(LANGUAGE) $(PLOT_SRC)

# Test Zipf's rule
ZIPF_SRC=zipf_test.py
ZIPF_EXE=python $(ZIPF_SRC)
ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC)
7 changes: 4 additions & 3 deletions code/09-conclusion-challenge-2/config.mk
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Count words script.
LANGUAGE=python
COUNT_SRC=wordcount.py
COUNT_EXE=python $(COUNT_SRC)
COUNT_EXE=$(LANGUAGE) $(COUNT_SRC)

# Plot word counts script.
PLOT_SRC=plotcount.py
PLOT_EXE=python $(PLOT_SRC)
PLOT_EXE=$(LANGUAGE) $(PLOT_SRC)

# Test Zipf's rule.
ZIPF_SRC=zipf_test.py
ZIPF_EXE=python $(ZIPF_SRC)
ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC)
15 changes: 9 additions & 6 deletions episodes/06-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ This is a variable [assignment]({{ page.root }}/reference#assignment) -
`COUNT_SRC` is assigned the value `wordcount.py`.

`wordcount.py` is our script and it is invoked by passing it to
`python`. We can introduce another variable to represent this
`python`. We can introduce another couple of variables to represent this
execution:

~~~
COUNT_EXE=python $(COUNT_SRC)
LANGUAGE=python
COUNT_EXE=$(LANGUAGE) $(COUNT_SRC)
~~~
{: .make}

Expand All @@ -42,8 +43,9 @@ is run. This is a variable [reference]({{ page.root }}/reference#reference). At
any place where we want to use the value of a variable we have to
write it, or reference it, in this way.

Here we reference the variable `COUNT_SRC`. This tells Make to
replace the variable `COUNT_SRC` with its value `wordcount.py`. When
Here we reference the variables `LANGUAGE` and `COUNT_SRC`. This tells Make to
replace the variable `LANGUAGE` with its value `python`,
and to replace the variable `COUNT_SRC` with its value `wordcount.py`. When
Make is run it will assign to `COUNT_EXE` the value `python
wordcount.py`.

Expand Down Expand Up @@ -74,12 +76,13 @@ the original makefile). Let us create `config.mk`:

~~~
# Count words script.
LANGUAGE=python
COUNT_SRC=wordcount.py
COUNT_EXE=python $(COUNT_SRC)
COUNT_EXE=$(LANGUAGE) $(COUNT_SRC)
# Test Zipf's rule
ZIPF_SRC=zipf_test.py
ZIPF_EXE=python $(ZIPF_SRC)
ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC)
~~~
{: .make}

Expand Down
5 changes: 3 additions & 2 deletions episodes/07-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,13 @@ Remember, the `config.mk` file contains:

~~~
# Count words script.
LANGUAGE=python
COUNT_SRC=wordcount.py
COUNT_EXE=python $(COUNT_SRC)
COUNT_EXE=$(LANGUAGE) $(COUNT_SRC)
# Test Zipf's rule
ZIPF_SRC=zipf_test.py
ZIPF_EXE=python $(ZIPF_SRC)
ZIPF_EXE=$(LANGUAGE) $(ZIPF_SRC)
~~~
{: .make}

Expand Down

0 comments on commit b140373

Please sign in to comment.