{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "93fdf6b1",
   "metadata": {},
   "source": [
    "# 15-06 · Ścieżki absolutne i względne\n",
    "\n",
    "Praktyka do sekcji [„Ścieżki: bezwzględne i względne”](/pl/chapters/rozdzial-15/15-06-puti-absolyutnye-i-otnositelnye.html)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "96054e01",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Rozróżniać ścieżkę względną od bezwzględnej i umieć uzyskać wariant bezwzględny przez .resolve()."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "2cb54dec",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T15:52:52.258257Z",
     "iopub.status.busy": "2026-08-18T15:52:52.258111Z",
     "iopub.status.idle": "2026-08-18T15:52:52.277508Z",
     "shell.execute_reply": "2026-08-18T15:52:52.276968Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from pathlib import Path\n",
    "\n",
    "Path(\"data\").mkdir(exist_ok=True)\n",
    "Path(\"data/a.txt\").write_text(\"привет\", encoding=\"utf-8\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d54d4584",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "be9ed9cc",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T15:52:52.278559Z",
     "iopub.status.busy": "2026-08-18T15:52:52.278441Z",
     "iopub.status.idle": "2026-08-18T15:52:52.281011Z",
     "shell.execute_reply": "2026-08-18T15:52:52.280543Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "from pathlib import Path\n",
    "\n",
    "rel = Path(\"data/a.txt\")\n",
    "abs_path = rel.resolve()\n",
    "print(rel.is_absolute())\n",
    "print(abs_path.is_absolute())"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c87e0c3d",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Sprawdź, czy nazwa pliku nie została utracona przy przejściu do ścieżki absolutnej."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9d882d88",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T15:52:52.281920Z",
     "iopub.status.busy": "2026-08-18T15:52:52.281809Z",
     "iopub.status.idle": "2026-08-18T15:52:52.284154Z",
     "shell.execute_reply": "2026-08-18T15:52:52.283781Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "from pathlib import Path\n",
    "\n",
    "rel = Path(\"data/a.txt\")\n",
    "abs_path = rel.resolve()\n",
    "imya_sovpadaet = abs_path.name == rel.name\n",
    "print(imya_sovpadaet)"
   ]
  }
 ],
 "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
}
