Relative PathsĪ relative path is the path that (as the name sounds) is relative to the working directory location on your computer. Then, you can create paths that are relative to that working directory, or create absolute paths, which means they begin at the home directory of your computer and provide the full path to the file that you wish to open. Within Python, you can define (or set) the working directory of your choice. When set correctly, working directories help the programming language to find files when you create paths. You may be wondering why working directories are important to understand when working with Python (or R or most scientific programming languages). Working Directories and Relative vs Absolute Paths in Python The data and output-plots directories are the immediately visible subdirectories within earth-analytics.īy setting your working directory to earth-analytics, you can easily access anything in both of those subdirectories. The image files (study-site.jpg and tree-species-distribution-map.jpg) exist within their parent directory: output-plots/spatial-vector directory. field-sites is the parent directory for the california directory, etc. In the example below, earth-analytics is the parent directory of both the data and output-plots subdirectories. It is the parent directory of any directories or files that get downloaded to your computer or placed within this directory. This also means that parent directories can also be subdirectories of a parent directory above them in the hierarchy.Īn example of a directory is your downloads directory. A parent directory can have many subdirectories thus, many subdirectories can share the same parent directory. ![]() The term “parent” directory is used to describe the preceding directory in which a subdirectory is created. However, the term directory considers the relationship between that folder and the folders within it and around it (it’s full path). Directories are hierarchical which means that they can exist within other folders as well as have folders exist within them.ĭata Tip: Directory vs Folder: You can think of a directory as a folder. The term “directory” considers the relationship between that folder and the folders within and around it. Below you will learn about some important terms associated with working with files including working and parent directories.Ī directory refers to a folder on a computer that has relationships to other folders. However, there are a set of terms that you will hear often, particularly as you work on open science projects or use the command line to manipulate files and directories. You have probably used files and directories on your computer before.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |