python-novice-gapminder icon indicating copy to clipboard operation
python-novice-gapminder copied to clipboard

Suggestion: introduce getcwd and listdir, and remove lesson content about Markdown

Open srtee opened this issue 4 years ago • 5 comments

I have helped in a few courses run based on the Gapminder material, and in common with Issue #528, getting to the correct directory and accessing the files is a common source of grief. My suggestion would be:

  1. put in material in Episode 1 covering working directories in Python, and
  2. remove the material on Markdown from the same Episode.

The high-level argument for (2) is that Markdown is not mentioned throughout the rest of the course material -- furthermore, it is more a feature of Jupyter and other notebook IDEs rather than Python itself. A Python learner will often be stumped by "File not found"-type errors from not knowing how to navigate directory structures in-script (including in the course itself!), far more than wanting to put a notebook cell into Markdown and not knowing how to.

This would entail the following changes:

Objectives

  • ~Create Markdown cells in a notebook.~
  • Print the current working directory and subdirectories and list their contents

Key Points

  • ~The Notebook will turn Markdown into pretty-printed documentation.~
  • ~Markdown does most of what HTML does.~
  • A Python script / JupyterLab notebook has a working directory.
  • The script / notebook will look for files in the working directory using a relative path.

and replacing the Markdown content with some exposition around an exercise to open a new Python cell, run the following commands, and describe the results:

from os import getcwd, listdir print(getcwd()) print(getcwd()+'/data')

print(listdir('data')) print(listdir(getcwd() + '/data'))

Learners can be reassured that they will understand the syntax a lot more later on in the course, but for now, they are just learning how to check their working directory and make sure they have their Gapminder data files. Any errors can be handled by instructors and helpers on the spot, making it much more likely that learners will have their scripts / notebooks open in the correct directories and that their data files are already accessible for future use. By moving out the Markdown material, this change will not lengthen the course (and indeed might shorten it by frontloading all the environment setup).

srtee avatar Jun 21 '21 01:06 srtee

Alternatively, the material on getcwd and listdir could be placed at the end of Episode 6 (Libraries), which will therefore showcase a very practical and essential example of Python library importing.

Since this would locate the exercise just before Episode 7, where data files are imported for the first time, we would also be introducing all file-system-related material together in a contiguous block and thus make it more memorable and accessible for learners.

srtee avatar Jun 21 '21 01:06 srtee

I really like this idea.

eldobbins avatar Jun 21 '21 16:06 eldobbins

Hello, I've started adding the os library to Episode 6, introducing the functions getcwd and listdir. It seems like it might be important to also include chdir in case students didn't start Jupyter in their home directory, what do you think?

Just to confirm, the markdown should still be removed from Episode 1? With the goal being to keep the total Lesson length approximately the same.

izaakm avatar Aug 04 '21 11:08 izaakm