Skip to content

Commit

Permalink
docs: fix encoding; clarify example is for setup.cfg (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwtoews committed Aug 22, 2023
1 parent ca6b491 commit f18ed30
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions docs/pages/patterns/data_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ data file, the naïve solution is just to hard-code the path to that file.
```python
from pathlib import Path

spacings_txt = Path("peak_spacings/LaB6.txt").read_text(encoding="utf=8")
spacings_txt = Path("peak_spacings/LaB6.txt").read_text(encoding="utf-8")
```

But this is not a good solution because:
Expand Down Expand Up @@ -111,7 +111,8 @@ package.peak_spacings =
```

**Or**, you can use automatic data inclusion (this is the default if you use
`pyproject.toml` `[project]` config in Setuptools 61+):
`pyproject.toml` `[project]` config in Setuptools 61+). To enable this with
`setup.cfg`:

```ini
[options]
Expand Down Expand Up @@ -139,7 +140,7 @@ import importlib_resources as resources

ref = resources.files("package.peak_spacings") / "LaB6.txt"

spacings_txt = ref.read_text(encoding="utf=8")
spacings_txt = ref.read_text(encoding="utf-8")

# If you have an API that requires an on-disk file, you can do this instead:
with resources.as_file(ref) as path:
Expand Down

0 comments on commit f18ed30

Please sign in to comment.