{"assignment":{"_schema_version":2,"course_id":37,"date_created":"2022-06-28T19:00:00+00:00","date_modified":"2023-09-10T14:15:04.408369+00:00","extra_instructor_files":"","extra_starting_files":"","forked_id":null,"forked_version":null,"hidden":false,"id":1098,"instructions":"## A System of Files\n\n![A picture modeling someone's file system. At the top is a folder labeled \"root\", with three arrows pointing downwards at three other folders. The first folder is labeled \"School work\" and has two files below (a word document and a excel spreadsheet). The second folder is labeled \"Photos\" and has two picture files in it. The third folder is labeled \"Python\" and has two Python files in it.](bakery_sequences_filesystems_directories.png)\n\nYour computer has a file system that lets you save and load files. A file is simply a sequence of data, not unlike a string. You create files all the time\u2014text documents, pictures, music, python files, and so on. These files are organized by your computer\u2019s file system.\n\n## Text Version\n\n```\nroot/\n  School work/\n      homework2.doc\n      cs10.xls\n  Photos/\n      Photo1.jpg\n      Me_irl.jpg\n  Python/\n      strings.py\n      example.py\n```\n\nThe previous diagram could be written as a hierarchy of text too.\nNotice how we use indentation to show the fils inside of folders.\n\n## Directories\n\n- **Directories:** A collection of files and directories\n- **Files:** A sequence of data external to a program\n\nDirectories, also known as folders, are a way to group files and other directories together.\nBecause we can put directories inside of directories, we end up with a _hierarchical_ system.\n\n## Paths\n\n![The model from before, with three layers of files and folders, is shown. A blue line traces a route from the Root down to one of the Python files with the label \"path\" on it.](bakery_sequences_filesystems_path.png)\n\nThink of files like a house. Directories are neighborhoods, cities, states, and successively bigger ways to group houses. Each file has a unique address within your file system called a _path_. We use these paths to navigate files and directories, just like we would navigate between houses and neighborhoods. In this diagram, the blue line is a path through the file system.\n\n## Absolute Path\n\n```\n/root/python/example.py\n/home/acbart/python/example.py\nC:/Users/acbart/python/example.py\nC:\\\\Users\\\\acbart\\\\python\\\\example.py\n```\n\nThe full address for a file is known as its _absolute path_.\nThe exact format of the path will depend on your platform, but typically they are a series of folder names separated by slashes.\nIn Python, it is typically best to use forward slashes since these tend to work regardless of the platform.\nOtherwise, you need to escape the backslashes with extra backslashes.\n\n## The Working Directory\n\n- **`pwd`**: Print the current working directory.\n- **`ls`**: List files in the current working directory.\n- **`ls path`**: List files in the directory of the path.\n- **`cd path`**: Change the current working directory to the given path\n\nMost modern programming environments, like Thonny or VS Code, have terminals (also known as command lines) that let you interact with the file system and run commands.\nThe commands available for the terminal vary depending on the kind of terminal. Python provides a special command line called the REPL (Read-Evaluate-Print-Loop) that allows you to interactively run Python statements and see the output. However, you are restricted to using regular Python language statements. There are other kinds of terminals available for different platforms, each with their own distinct commands. The most common kind of terminals do not actually support Python commands; instead, they support their own special set of commands for interacting with the file system:\n\nIt might seem a little confusing, but it\u2019s important to recognize the difference between the Python terminal (which starts with three angle brackets `>>>`) and the regular terminal (which can start with many different kinds of symbols, such as `$>`).\n\n## Current Working Directory\n\n```sh\n$> pwd\nC:/Users/acbart/projects/pythonmisc/\n```\n\nA regular terminal usually has a **_current working directory_**, which is where you are now in the file system.\nIn VS Code, you can check your current directory using the `pwd` command with an exclamation mark in front of it.\nPWD stands for **_print working directory_**.\nNote that this only works in the Thonny command line; it's not actually a Python command.\nIn the regular command line, you would not need the exclamation mark either.\n\n## Relative Paths\n\n```sh\n$> ls\n\nDate        Time        Type  Size     Name\n09/17/2017  09:41 PM    <DIR>          .\n09/17/2017  09:41 PM    <DIR>          ..\n09/12/2017  03:11 PM    <DIR>          photos\n09/14/2017  05:34 PM    <DIR>          music\n09/11/2017  02:45 PM    <DIR>          python\n09/02/2016  06:08 PM             6,228 homework5.pdf\n09/02/2016  06:08 PM             9,650 example.py\n08/08/2015  07:43 PM           340,489 historyOfDogs.png\n08/08/2015  07:44 PM           422,316 taxReturns.docx\n```\n\nAn **_absolute path_** only works on your own computer.\nGiving someone else an absolute path will usually not work, since most people will organize their computer differently.\nTherefore, it is usually better to use a **_relative path_** to make your program easier to share with other people.\nA relative path is the part of an absolute path minus the current working directory, which means a relative path will usually be much shorter than an absolute path.\n\nIf there are folders in your current working directory, you can reference them without writing the absolute path.\nInstead, the folder's path is simply its name.\nYou can see a list of the folders in your current directory by using the `ls` command.\n`ls` stands for \"list\", as in \"list the files\".\n\n## Moving between directories\n\n```sh\n# Absolute path:\n# Move to specific folder anywhere in your file system\n$> cd /c/Users/acbart/projects\n\n# Relative path:\n# Move to folder in current directory\n$> cd pythonmisc/\n\n# Move up a level\n$> cd ../\n```\n\nTo move the current working directory to another, we use the `cd` command (\"change directories\").\nYou can move to an absolute path or a relative path. You can also move up a folder level by using a pair of periods.\nThe folder above the current folder is called the parent folder in the path.\n\n## Commands\n\n![A listing of the previously described commands and their meaning.](bakery_sequences_filesystems_command_table.png)\n\nIt can be tricky to remember these commands, but knowing how to use them will serve you well when you start working on larger projects.\n\n## Summary\n\n- File systems are organized collections of files and directories.\n- Directories are collections of files and other directories.\n- Files are a collection of data that can be read and written from programs to preserve and share data between executions of a program.\n- Terminals allow you to interact with a file system using specialized commands:\n  - You can use the `cd` command to change the current working directory.\n  - You can use the `pwd` command to print the current working directory.\n  - You can use the `ls` command to list the files in a given path or in the current working directory.\n- Python's REPL terminal is different from the regular terminal.","ip_ranges":"","name":"7B1) Filesystems Reading","on_change":"","on_eval":"","on_run":"","owner_id":1,"owner_id__email":"acbart@udel.edu","points":0,"public":true,"reviewed":false,"sample_submissions":[],"settings":"{\n  \"header\": \"Filesystems\",\n  \"youtube\": {\n    \"Bart\": \"o5Jq_eZzAlU\",\n    \"Amy\": \"bE7s1EY52tc\"\n  },\n  \"video\": {\n    \"Bart\": \"https://blockpy.cis.udel.edu/videos/bakery_sequences_filesystems-Bart.mp4\",\n    \"Amy\": \"https://blockpy.cis.udel.edu/videos/bakery_sequences_filesystems-Amy.mp4\"\n  },\n  \"small_layout\": true,\n  \"hide_files\": false,\n  \"summary\": \"In this lesson, you will learn about your computer's File System. Files are an important part of making programs useful, because they allow us to persist information between runs of a program. Files are organized into directories within your file system, and are uniquely identified by paths.\"\n}","starting_code":"","subordinate":true,"tags":[],"type":"reading","url":"bakery_sequences_filesystems_read","version":8},"ip":"216.73.216.157","submission":{"_schema_version":3,"assignment_id":1098,"assignment_version":8,"attempts":0,"code":"","correct":false,"course_id":37,"date_created":"2026-05-20T14:01:47.140052+00:00","date_due":"","date_graded":"","date_locked":"","date_modified":"2026-05-20T14:01:47.140052+00:00","date_started":"","date_submitted":"","endpoint":"","extra_files":"","feedback":"","grading_status":"NotReady","id":2036914,"score":0.0,"submission_status":"Started","time_limit":"","url":"submission_url-97d31a14-d814-44f4-b624-9bde71522346","user_id":2044668,"user_id__email":"","version":0},"success":true}
