<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/til-139-multiline-input-in-the-repl-wilgwsbhh" -->

---
title: TIL #139 – Multiline input in the REPL | daily.dev
description: Using `open(0)` in Python&#x27;s REPL opens standard input, enabling multiline input capture. However, calling it repeatedly causes an `OSError` because Python...
canonical: https://daily.dev/posts/til-139-multiline-input-in-the-repl-wilgwsbhh
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: TIL #139 – Multiline input in the REPL | daily.dev
og:description: Using `open(0)` in Python&#x27;s REPL opens standard input, enabling multiline input capture. However, calling it repeatedly causes an `OSError` because Python...
og:url: https://daily.dev/posts/til-139-multiline-input-in-the-repl-wilgwsbhh
og:image: https://api.daily.dev/og/posts/wiLgwsBhH.png
og:image:alt: TIL #139 – Multiline input in the REPL
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# TIL #139 – Multiline input in the REPL

**[Planet Python](https://daily.dev/sources/planetpython)** · 2 min read · 0 upvotes · 0 comments

## Summary

Using `open(0)` in Python's REPL opens standard input, enabling multiline input capture. However, calling it repeatedly causes an `OSError` because Python closes file descriptor 0 after the first read. The fix is to pass `closefd=False` to `open()`, which keeps the file descriptor open and allows repeated multiline reads in the same REPL session.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://mathspp.com/blog/til/multiline-input-in-the-repl>

## Similar posts on daily.dev

- [Brillant Python Programmers](https://daily.dev/posts/brillant-python-programmers-xaqe6dj7t) · The Daily WTF · 1 upvotes · 0 comments
- [TIL: Python's splitlines does a lot more than just newlines](https://daily.dev/posts/til-python-s-splitlines-does-a-lot-more-than-just-newlines-inmbseyhe) · Lobsters · 2 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python)

[View this post on daily.dev](https://daily.dev/posts/til-139-multiline-input-in-the-repl-wilgwsbhh)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"TIL #139 – Multiline input in the REPL","url":"https://daily.dev/posts/til-139-multiline-input-in-the-repl-wilgwsbhh","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/til-139-multiline-input-in-the-repl-wilgwsbhh"},"datePublished":"2026-03-02T16:46:52.665Z","dateModified":"2026-03-02T16:47:12.081Z","description":"Using `open(0)` in Python's REPL opens standard input, enabling multiline input capture. However, calling it repeatedly causes an `OSError` because Python...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/fa31c0471bde00e0c95f1b4ab0db6dff?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/fa31c0471bde00e0c95f1b4ab0db6dff?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Planet Python","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Planet Python","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/eac3cc584cb043b5a242d13752bd3d0c","url":"https://daily.dev/sources/planetpython"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/til-139-multiline-input-in-the-repl-wilgwsbhh","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python","timeRequired":"PT2M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Planet Python","item":"https://daily.dev/sources/planetpython"},{"@type":"ListItem","position":3,"name":"TIL #139 – Multiline input in the REPL"}]}
```

