---
jupyter:
  orphan: true
  jupytext:
    text_representation:
      extension: .Rmd
      format_name: rmarkdown
      format_version: '1.2'
      jupytext_version: 1.11.5
  kernelspec:
    display_name: Python 3 (ipykernel)
    language: python
    name: python3
---

# Making and breaking file paths in Python

## Pathnames

A pathname is a string that identifies a particular file or directory on a
computer filesystem.

For example, we can ask the pathname of the directory containing this notebook, using the `getcwd` function from the `os` module.

```{python}
import os

os.getcwd()
```

## Two ways of manipulating pathnames

There are two standard ways of manipulating pathnames in Python.

* [The pathlib module](pathlib.Rmd)
* [The os.path module](os_path.Rmd)

Of the two techniques, the `os.path` way is rather simpler, but it covers a
smaller range of tasks.  It can also be more verbose. `pathlib` does more, and
can give you nice-looking, concise code, but it does rely on a particularly
Python way of thinking.   You will see examples of both in lots of modern code,
but we will use `pathlib` in this textbook, because it will likely be the
method you end up using when you are more experienced writing Python code.
