Skip to content

Add open and with chapter - #60

Open
RamonRDR wants to merge 1 commit into
mainfrom
phase-07-open-and-with
Open

Add open and with chapter#60
RamonRDR wants to merge 1 commit into
mainfrom
phase-07-open-and-with

Conversation

@RamonRDR

@RamonRDR RamonRDR commented Aug 19, 2026

Copy link
Copy Markdown
Owner

Summary

  • continue Phase 7: Errors, Files, and Modules with Chapter 03, Opening Files Safely with open() and with, in English, Brazilian Portuguese, and Spanish
  • teach file objects, text modes r, w, a, and x, explicit encodings, reading, writing, appending, line iteration, newline handling, and relative versus absolute paths
  • connect with to context-managed cleanup and contrast it with manual try / finally
  • introduce focused handling of common file exceptions and separation between file I/O, parsing, validation, and later structured-data concerns
  • add three deterministic, non-interactive examples using temporary directories so the approved-example runner leaves no repository files behind
  • synchronize Phase 7 indexes, root/localized status pages, master learning paths, roadmaps, project-structure documents, and the approved example manifest
  • keep Phase 7 in progress and set TXT, CSV, and JSON as the next planned chapter

Validation target

  • aligned EN / PT-BR / ES chapter structure
  • identical Python code blocks across the three chapter versions
  • 3 new executable examples
  • 112 approved unattended examples
  • exactly 22 changed files
  • one focused commit based exactly on main at 56a6fffadd39fddce8376347f9c82e8de49c0d58
  • Repository quality checks green on the final PR head

References

The chapter is grounded in the official Python 3.14 documentation for open(), the tutorial section on reading and writing files, context-manager semantics for with, and the built-in hierarchy for file and operating-system exceptions.

@RamonRDR RamonRDR closed this Aug 19, 2026
@RamonRDR
RamonRDR force-pushed the phase-07-open-and-with branch from ee5945e to 56a6fff Compare August 19, 2026 01:31
@RamonRDR RamonRDR reopened this Aug 19, 2026
@RamonRDR
RamonRDR force-pushed the phase-07-open-and-with branch from e3f17bd to cbd62ac Compare August 19, 2026 01:41
@RamonRDR
RamonRDR marked this pull request as ready for review August 19, 2026 01:42

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cbd62ac099

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread errors-files-and-modules/03-open-and-with/README.md Outdated
@RamonRDR
RamonRDR force-pushed the phase-07-open-and-with branch from da31ab0 to e409357 Compare August 19, 2026 09:44

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e4093571b0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


Programs often need data to survive after the process ends. A text file can store notes, configuration, exports, logs, or intermediate results that a later execution can read again.

Python's built-in `open()` function creates a **file object** connected to a file or another file-like resource. The `with` statement gives that resource a clear lifetime so it is closed even when the block exits because of an exception.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Limit open() inputs to paths and descriptors

open() does not connect to an arbitrary file-like resource: it accepts a path-like value or an integer file descriptor, while passing an existing stream such as io.StringIO() raises TypeError. This wording, repeated in both translations, can therefore teach beginners that existing streams should be wrapped with open(); describe the input as a filesystem path or file descriptor instead.

AGENTS.md reference: AGENTS.md:L7-L9

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant