File paths in Python

It would be good to review how file paths are used in Python compared to how they are represented in Windows. In Python, file paths are strings, and strings in Python have special characters used to represent tabs (\t), newlines (\n), or carriage returns (\r), among many others. These special characters all incorporate single backslashes, making it very hard to create a file path that uses single backslashes. This would not be a big deal, except that file paths in Windows Explorer all use single backslashes.

There are a number of methods used to avoid this issue. Python was developed within the Linux environment, where file paths have forward slashes. This more Pythonic representation is also available when using Python in ...

Get ArcPy and ArcGIS – Geospatial Analysis with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.