{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a7647f47",
   "metadata": {},
   "source": [
    "# 15-08 · pathlib.Path: ścieżki jako obiekty\n",
    "\n",
    "Praktyka do sekcji [„pathlib.Path: ścieżki jako obiekty”](/pl/chapters/rozdzial-15/15-08-pochemu-pathlib.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dbac3fc4",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Zbieraj ścieżkę przez/zamiast łańcuchów konkatenacji."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b53c0e58",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "2843c2c5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T15:52:53.870769Z",
     "iopub.status.busy": "2026-08-18T15:52:53.870669Z",
     "iopub.status.idle": "2026-08-18T15:52:53.892385Z",
     "shell.execute_reply": "2026-08-18T15:52:53.891891Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "data/players/anna.json\n",
      "anna.json\n",
      "data/players\n"
     ]
    }
   ],
   "source": [
    "from pathlib import Path\n",
    "\n",
    "file_path = Path(\"data\") / \"players\" / \"anna.json\"\n",
    "print(file_path)\n",
    "print(file_path.name)\n",
    "print(file_path.parent.as_posix())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "78037e77",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Zbuduj ścieżkę o jeden poziom głębiej i sprawdź, czy liczba jej części wzrosła."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "f216a961",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T15:52:53.893328Z",
     "iopub.status.busy": "2026-08-18T15:52:53.893208Z",
     "iopub.status.idle": "2026-08-18T15:52:53.895701Z",
     "shell.execute_reply": "2026-08-18T15:52:53.895247Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "from pathlib import Path\n",
    "\n",
    "file_path = Path(\"data\") / \"players\" / \"anna.json\"\n",
    "deeper_path = Path(\"data\") / \"players\" / \"guilds\" / \"anna.json\"\n",
    "parts_increased = len(deeper_path.parts) > len(file_path.parts)\n",
    "print(parts_increased)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Cartesian Python 3.14",
   "language": "python",
   "name": "cartesian-python314"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.14.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
