Python for Actuarial Students · Course 0W
Module 1

The Windows File System, Demystified

Drives, paths, slashes, hidden files, and where your work actually lives — the foundation for everything that follows.

Module 1 · OverviewBy the end of this module you can…

  • Explain the difference between a disk, a file system, and what Explorer shows you
  • Read and write absolute and relative paths with confidence
  • Know when to use / versus \ — and why Python prefers /
  • Reveal file extensions and hidden items in Explorer
  • Find your way around your user profile and AppData
  • Set up a safe workspace at C:\actuarial_work\, outside OneDrive
45 min
Concepts & demos
40 min
Hands-on lab
Part 1

A Mental Model

What a disk actually is — and why Explorer is only one (opinionated) view of it.

Mental modelThree layers, not one

The diskA long numbered list of storage blocks. It knows nothing about “files”.
→
The file systemNTFS on Windows: an index that names blocks, groups them into files, and files into folders.
→
ExplorerA friendly view of the file system — with shortcuts, icons, and things deliberately hidden.

Programming tools talk to the file system directly, not to Explorer. When Explorer “hides” something, your code still sees it — and when Explorer shows a shortcut like Quick access, your code does not.

Mental modelWhat Explorer shows vs. where things really are

Explorer says…The real path is often…Why it matters
DesktopC:\Users\Jane\OneDrive\DesktopMay be silently synced to the cloud
DocumentsC:\Users\Jane\OneDrive\DocumentsSame — “Known Folder Move”
DownloadsC:\Users\Jane\DownloadsUsually not synced
Quick access / Homenowhere — it’s a list of shortcutsCan’t cd into it
This PCnowhere — a virtual summary of drivesNot a real folder

Click the Explorer address bar (or press Alt+D): the breadcrumb turns into the real path. Get into this habit now.

Mental modelIt’s all one tree

Every drive is an upside-down tree:

  • The root is the drive itself: C:\
  • Folders (a.k.a. directories) are branches
  • Files are leaves
  • A path is the route from the root to a leaf

Programmers say “directory”; Windows says “folder”. Same thing.

C:\
├── Program Files\      apps (admin only)
├── Windows\            the OS — hands off
├── Users\
│   └── Jane\            your "home"
│       ├── AppData\     hidden!
│       ├── Desktop\
│       ├── Documents\
│       └── Downloads\
└── actuarial_work\     ← we'll make this
    └── pricing\
        ├── model.py
        └── data\
            └── input.csv

DrivesDrive letters and volumes

LetterTypically
C:The system drive — Windows, apps, users
D:, E:…Second disks, USB sticks, SD cards
H:, S:…Mapped network drives at work/school

A: and B: were reserved for floppy disks — which is why the system drive is C:.

Network paths (UNC)

A mapped drive is a nickname for a UNC path:

H:\  →  \\fileserver01\home\jane
S:\  →  \\corp.local\shared\Actuarial

Network drives are slow for thousands of small files and may vanish off-VPN. Keep code and environments on your local disk.

DrivesOneDrive: helpful for Word, hazardous for code

Sync storms

A Python environment holds tens of thousands of small files. OneDrive tries to upload every one.

Locked & duplicated files

Sync locks files mid-write, then “resolves” conflicts with copies like model-LAPTOP-7F.py.

Files-on-demand

Cloud-only placeholders (☁) look present in Explorer but aren’t on disk when your code needs them.

Rule for this course: code lives in C:\actuarial_work\, which OneDrive doesn’t touch. Backups and history come from Git + GitHub (Module 5), which is designed for code.

Part 2

File Paths

Absolute vs. relative, and the tale of two slashes.

PathsAnatomy of an absolute path

C:\Users\Jane\projects\model.py

Drive

C: — which volume

Folders

Users\Jane\projects — the route down the tree

Name

model — the file’s stem

Extension

.py — what kind of file

An absolute path starts at the root. It means the same thing no matter where you are.

Downside: it only works on your machine. Your colleague isn’t called Jane.

PathsRelative paths: directions from where you stand

A relative path starts from the current working directory (CWD).

.this folder
..the parent folder
data\input.csvdown into data
..\data\input.csvup one, then down
C:\actuarial_work\pricing\
├── data\
│   └── input.csv
├── notebooks\        ← you are here
│   └── explore.ipynb
└── src\
    └── model.py

From notebooks\, the data file is ..\data\input.csv. From the project root it’s just data\input.csv.

Relative paths make projects portable: zip the folder, send it to a colleague, and every path still works.

Check yourselfResolve these paths

Your CWD is C:\actuarial_work\pricing\src. Where does each point?

Relative pathResolves to
model.pyC:\actuarial_work\pricing\src\model.py
..\data\input.csvC:\actuarial_work\pricing\data\input.csv
..\..C:\actuarial_work
.\..\src\.\model.pyC:\actuarial_work\pricing\src\model.py (silly but legal)

SlashesForward /, back \, and escaping

  • Windows traditionally separates folders with \
  • Most Windows APIs also accept /
  • But in most programming languages, \ inside a string is an escape character: \n = newline, \t = tab

That innocent-looking path contains a newline and a tab. Python will look for a file that doesn’t exist — or error out.

# ❌ Broken: \n and \t are escape sequences
path = "C:\new_data\tables.csv"

# ✅ Option 1: forward slashes (preferred)
path = "C:/new_data/tables.csv"

# ✅ Option 2: a raw string — backslashes taken literally
path = r"C:\new_data\tables.csv"

# ✅ Option 3: escape each backslash
path = "C:\\new_data\\tables.csv"

InterludeMeanwhile, in UNIX-land (Linux, BSD, macOS)

  • One tree, rooted at / — no drive letters
  • Other disks are mounted as folders: /mnt/usb, /Volumes/USB
  • Home is /home/jane (Linux) or /Users/jane (macOS), shortened to ~
  • File names are usually case-sensitive: Data.csv ≠ data.csv
  • Network shares are //server/share or smb://server/share
/
├── bin/
├── etc/
├── home/
│   └── jane/          ~
│       └── actuarial_work/
└── mnt/
    └── usb/           a "drive"

In UNIX, \ is never a path separator — in file paths or network paths. It is only an escape character.

InterludeWhy Python wants you to use / — even on Windows

  • Python on Windows happily accepts /
  • No escaping headaches
  • The same code runs unchanged on Linux & macOS
  • Better still: pathlib builds paths for you and prints them the native way
from pathlib import Path

project = Path("C:/actuarial_work/pricing")
data_file = project / "data" / "input.csv"   # "/" joins parts

print(data_file)           # C:\actuarial_work\pricing\data\input.csv
print(data_file.suffix)    # .csv
print(data_file.exists())  # True / False

home = Path.home()         # C:\Users\Jane  (or /home/jane)

House rule: write / in your code; let Windows show you \ in Explorer.

Part 3

What Explorer Hides From You

File extensions, hidden items, and your user profile.

ExtensionsThe case of model.py.txt

By default, Explorer hides known file extensions. So:

  1. You save model.py from Notepad
  2. Notepad quietly adds .txt
  3. Explorer shows model.py — looks perfect
  4. Python says file not found 🤯
Explorer showsActual name
model.pymodel.py.txt
claimsclaims.csv
invoice.pdfinvoice.pdf.exe ⚠️

The last row is a classic malware trick. Showing extensions is a security habit, too.

ExtensionsTurn on extensions & hidden items

Windows 11

  1. Open Explorer (Win+E)
  2. View → Show
  3. Tick File name extensions
  4. Tick Hidden items

Windows 10

  1. Open Explorer (Win+E)
  2. Click the View ribbon tab
  3. Tick File name extensions
  4. Tick Hidden items

Once hidden items are visible, you’ll start seeing programmer furniture:

.git\   .venv\   .gitignore   .python-version   AppData\

Names starting with a dot are a UNIX convention for “hidden”; you’ll create plenty of them in this course.

User profileYour home: C:\Users\<username>

C:\Users\Jane\          %USERPROFILE%, $HOME, ~
├── .local\bin\        uv installs here (Mod 4)
├── AppData\           hidden
│   ├── Local\          caches, per-machine
│   ├── LocalLow\       sandboxed apps
│   └── Roaming\        settings that follow you
├── Desktop\
├── Documents\
├── Downloads\
├── OneDrive\
└── .gitconfig          Git settings (Mod 5)
  • Everything in here is yours — no admin rights needed
  • Three names for the same folder:
    • %USERPROFILE% — Explorer / cmd
    • $HOME or ~ — PowerShell
    • Path.home() — Python

Type %USERPROFILE% or %LOCALAPPDATA% into Explorer’s address bar and press Enter.

User profileAppData: where programs keep their stuff

FolderHoldsExample
AppData\Roaming
%APPDATA%
Small settings meant to follow you between machines on a corporate networkCode\User\settings.json (VS Code)
AppData\Local
%LOCALAPPDATA%
Large, machine-specific data: caches, per-user installsuv\cache\, Programs\Microsoft VS Code\
AppData\LocalLowLow-trust / sandboxed apps (browsers, some games)—

Browse it to understand it — but don’t delete things in AppData unless you know which program owns them.

PermissionsFile permission basics

Yours

C:\Users\Jane\… and folders you create, like C:\actuarial_work.

Read, write, delete freely.

Admin only

C:\Program Files, C:\Windows, other users’ profiles.

Triggers a UAC prompt.

Locked

A file open in another program — e.g. a workbook in Excel (look for ~$claims.xlsx).

“Permission denied” even though it’s yours.

Every tool in this course installs per-user, inside your profile. You should almost never need “Run as administrator”.

Hands-on Lab · 40 minSet up your workspace

  1. Unmask file extensions and hidden items
  2. Trap yourself with model.py.txt — then escape
  3. Create C:\actuarial_work\ outside OneDrive
  4. Navigate the tree using only the keyboard

Deliverable

A folder structure like this, verified via the address bar:

C:\actuarial_work\
└── sandbox\
    ├── data\
    ├── notebooks\
    └── notes.txt

Lab · Steps 1–2Unmask the extensions

  1. Open Explorer → View → Show → tick File name extensions and Hidden items.
  2. Visit %USERPROFILE%. Find AppData (now visible, slightly faded).
  3. Open Notepad, type print("hello"), and Save As model.py on the Desktop with “Save as type: Text Documents”.
  4. Look at the Desktop in Explorer. What is the real name? → model.py.txt
  5. Rename it (F2) to model.py and accept the “change extension” warning.

In Notepad’s Save dialog, choose All files (*.*) to prevent the extra .txt.

Lab · Step 3Create C:\actuarial_work\

  1. In Explorer, go to This PC → Local Disk (C:).
  2. New folder (Ctrl+Shift+N) → name it actuarial_work.
  3. Inside, create sandbox, and inside that, data and notebooks.
  4. Move the model.py from your Desktop into sandbox.
  5. Click the address bar: confirm it reads C:\actuarial_work\sandbox — no OneDrive in the path.

Use lowercase and underscores; no spaces. actuarial_work — not Actuarial Work. Spaces in paths cause quoting pain on the command line (Module 2).

Can’t create folders in C:\ on a locked-down work laptop? Use C:\Users\<you>\actuarial_work instead — still outside OneDrive.

Lab · Step 4Navigate without the mouse

KeysAction
Win+EOpen Explorer
Alt+D or Ctrl+LJump to address bar
Alt+↑Up to parent folder (..)
Alt+← / →Back / forward
Type lettersJump to matching item
F2Rename
Ctrl+Shift+CCopy as path (Win 11)

Challenge

  1. From the Desktop, reach C:\actuarial_work\sandbox\data by typing the path.
  2. Climb to C:\ with only Alt+↑. How many presses?
  3. Create notes.txt in sandbox and copy its full path to the clipboard.
  4. Type wt in the address bar and press Enter. (Teaser for Module 2!)

RecapModule 1 checklist

  • I can explain disk vs. file system vs. Explorer
  • I can read an absolute path and resolve a relative one using . and ..
  • I know why "C:\new\table.csv" breaks in Python, and three ways to fix it
  • I write / in code (or use pathlib)
  • Extensions and hidden items are visible on my machine
  • I know where AppData, %USERPROFILE%, and ~ point
  • My workspace C:\actuarial_work\ exists, outside OneDrive
Up next
Module 2

The Command Line

Everything you just did with the mouse — faster, repeatable, and scriptable, with Windows Terminal and PowerShell.