I ran into a hiccup teaching this lesson while trying to explain the utility of a scripts folder. Since python scripts are also modules that can be imported, you can easily use them in root level Jupyter notebooks with a simple import. But, there is a gotcha introduced by Anaconda. If you place the example.py file described in the lesson within scripts the following fails on Anaconda:
import scripts.example
Anaconda has a built-in package named scripts that shadows the scripts folder. I think the most pythonic way out of this is to suggest inclusion of an __init__.py file within the scripts folder. It may seem advanced, but it's easy enough to do/mention, and may be interesting to some students.
- **`scripts/`**: Use this folder to store your (Python) scripts for data cleaning, analysis, and plotting that you use or import in this particular project. If you intend to import the scripts, consider initiating the folder with an empty file named `__init__.py`.
Thanks to @vinisalazar for sleuthing the error live while I was teaching.
I ran into a hiccup teaching this lesson while trying to explain the utility of a
scripts
folder. Since python scripts are also modules that can be imported, you can easily use them in root level Jupyter notebooks with a simpleimport
. But, there is a gotcha introduced by Anaconda. If you place theexample.py
file described in the lesson withinscripts
the following fails on Anaconda:Anaconda has a built-in package named scripts that shadows the scripts folder. I think the most pythonic way out of this is to suggest inclusion of an
__init__.py
file within thescripts
folder. It may seem advanced, but it's easy enough to do/mention, and may be interesting to some students.Proposed change is to:
https://github.com/datacarpentry/python-ecology-lesson/blob/032c1ee31a018825a692b914aa9cc99f73626e88/_episodes/00-before-we-start.md#L107
Amend it to:
Thanks to @vinisalazar for sleuthing the error live while I was teaching.