{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "a93ee7fd",
   "metadata": {},
   "source": [
    "# 15-21 · Zmiana nazwy, kopiowanie, usuwanie\n",
    "\n",
    "Praktyka do sekcji [„Zmiana nazw, kopiowanie, usuwanie”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5d77cc63",
   "metadata": {},
   "source": [
    "## Sprawa robocza"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "bf3019d5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T15:53:04.330900Z",
     "iopub.status.busy": "2026-08-18T15:53:04.330734Z",
     "iopub.status.idle": "2026-08-18T15:53:04.352713Z",
     "shell.execute_reply": "2026-08-18T15:53:04.352237Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True True\n"
     ]
    }
   ],
   "source": [
    "from pathlib import Path\n",
    "import shutil\n",
    "\n",
    "Path(\"chernovik2.txt\").write_text(\"draft\", encoding=\"utf-8\")\n",
    "Path(\"chernovik2.txt\").rename(\"gotovo2.txt\")\n",
    "rename_ok = Path(\"gotovo2.txt\").exists() and not Path(\"chernovik2.txt\").exists()\n",
    "\n",
    "shutil.copy(\"gotovo2.txt\", \"gotovo2_backup.txt\")\n",
    "copy_ok = Path(\"gotovo2_backup.txt\").read_text(encoding=\"utf-8\") == \"draft\"\n",
    "print(rename_ok, copy_ok)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "805f7918",
   "metadata": {},
   "source": [
    "## Zadanie ★ Podstawowa praktyka — bezpieczne usuwanie"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "8169616a",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-18T15:53:04.353791Z",
     "iopub.status.busy": "2026-08-18T15:53:04.353601Z",
     "iopub.status.idle": "2026-08-18T15:53:04.356258Z",
     "shell.execute_reply": "2026-08-18T15:53:04.355828Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n"
     ]
    }
   ],
   "source": [
    "from pathlib import Path\n",
    "\n",
    "Path(\"vremenny2.txt\").write_text(\"temp\", encoding=\"utf-8\")\n",
    "Path(\"vremenny2.txt\").unlink()\n",
    "delete_ok = not Path(\"vremenny2.txt\").exists()\n",
    "print(delete_ok)"
   ]
  }
 ],
 "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
}
