datacarpentry / python-ecology-lesson

Data Analysis and Visualization in Python for Ecologists

Home Page:https://datacarpentry.org/python-ecology-lesson

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Anaconda `scripts` module and the scripts folder

itcarroll opened this issue · comments

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.

Proposed change is to:

- **`scripts/`**: Use this folder to store your (Python) scripts for data cleaning, analysis, and

Amend it to:

 - **`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.

Fixed by @nels in #477