GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Please add argument to override stdin/out/err in the input builtin · Issue #75784 · python/cpython

Please add argument to override stdin/out/err in the input builtin #75784

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Please add argument to override stdin/out/err in the input builtin#75784
Copy link
Labels
3.7 (EOL)end of lifeend of lifetopic-IO

Description

wt
mannequin
opened on Sep 27, 2017
Issue body actions
BPO 31603
Nosy @bitdancer, @wt, @serhiy-storchaka, @csabella, @tonybaloney, @iritkatriel
PRs
  • bpo-31603 Add file args to input builtin #3814
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2017-09-27.06:34:07.094>
    labels = ['3.7', 'expert-IO']
    title = 'Please add argument to override stdin/out/err in the input builtin'
    updated_at = <Date 2022-01-20.18:29:21.436>
    user = 'https://github.com/wt'

    bugs.python.org fields:

    activity = <Date 2022-01-20.18:29:21.436>
    actor = 'wt'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['IO']
    creation = <Date 2017-09-27.06:34:07.094>
    creator = 'wt'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 31603
    keywords = ['patch']
    message_count = 9.0
    messages = ['303103', '303105', '303132', '303135', '303297', '338208', '341587', '410816', '411041']
    nosy_count = 6.0
    nosy_names = ['r.david.murray', 'wt', 'serhiy.storchaka', 'cheryl.sabella', 'anthonypjshaw', 'iritkatriel']
    pr_nums = ['3814']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue31603'
    versions = ['Python 3.7']

    Activity

    1. wt commented on Sep 27, 2017

      @wt
      wtmannequin
      on Sep 27, 2017
      MannequinAuthor
      More actions

      I would really love to add a few params to input so that it's signature looked more like so:

      def input(prompt, /, *, fin=sys.stdin, fout=sys.stdout, ferr=sys.stderr):
          ...

      This would certainly make overriding the the files in specific calls to input easier. A reasonable use case is collecting a piece over /dev/tty explicitly so that a redirected stdin could be used to pipe data into a program while overriding using /dev/tty to collect some piece of data. Here's some code illustrating what I'd like:

      import sys
      sys.stdin.close()
      sys.stdin = open('/dev/null', 'r')
      with open('/dev/tty', 'r') as f:
          x = input('Name? ', fin=f)
      print(x)

      FWIW, I have actually already implemented this fully (including tests). I am just trying to see what I need to do to allow release since I am work on my employer's time.

      In the interest of getting feedback, does the signature provided above look sane?

    2. wt
      added
      3.7 (EOL)end of lifeend of life
      topic-IO
      on Sep 27, 2017
    3. wt commented on Sep 27, 2017

      @wt
      wtmannequin
      on Sep 27, 2017
      MannequinAuthor
      More actions

      This might also allow simplification of the getpass.unix_getpass() logic. I am not 100% sure about that yet though.

    4. bitdancer commented on Sep 27, 2017

      @bitdancer
      bitdancer
      on Sep 27, 2017
      Member
      More actions

      This is probably a topic for the python-ideas mailing list. For example, rather than complicating input, it might be better to propose adding a redirect_stdin to contextlib to parallel the two existing redirect context managers. I don't remember why that was not added when the others were, but there was probably a reason, so a discussion about what the best solution is for the use case is in order, and python-ideas is the place for that.

      Reacted by Bartosz Sławecki
    5. serhiy-storchaka commented on Sep 27, 2017

      @serhiy-storchaka
      serhiy-storchaka
      on Sep 27, 2017
      Member
      More actions

      input() is a convenient function for simple user interaction. If you need to read a data from different file object just use its readline() method.

    6. wt commented on Sep 29, 2017

      @wt
      wtmannequin
      on Sep 29, 2017
      MannequinAuthor
      More actions

      Added a PR to facilitate discussion on python-ideas.

    7. csabella commented on Mar 18, 2019

      @csabella
      csabella
      on Mar 18, 2019
      Contributor
      More actions

      For reference, here's the link to the Python ideas thread:

      https://mail.python.org/pipermail/python-ideas/2017-September/047230.html

    8. tonybaloney commented on May 6, 2019

      @tonybaloney
      tonybaloneymannequin
      on May 6, 2019
      Mannequin
      More actions

      The discussion on python-ideas has some unresolved questions. Wren, did you get a definitive answer on this idea?

    9. iritkatriel commented on Jan 17, 2022

      @iritkatriel
      iritkatriel
      on Jan 17, 2022
      Member
      More actions

      See also bpo-1927.

    10. wt commented on Jan 20, 2022

      @wt
      wtmannequin
      on Jan 20, 2022
      MannequinAuthor
      More actions

      I'm not sure that I ever got a definitive issue, but I didn't have time to
      push it forward. I still think the idea has merit. I'd love to see it
      implemented, but I don't have the time to pursue it right now.

      Thanks,
      wt

      On Mon, Jan 17, 2022 at 10:23 AM Irit Katriel <[email protected]>
      wrote:

      Irit Katriel <[email protected]> added the comment:

      See also bpo-1927.

      ----------
      nosy: +iritkatriel


      Python tracker <[email protected]>
      <https://bugs.python.org/issue31603\>


    11. ezio-melotti
      transferred this issue fromon Apr 10, 2022
    12. iritkatriel commented on Oct 29, 2022

      @iritkatriel
      iritkatriel
      on Oct 29, 2022
      Member
      More actions

      [...] I don't have the time to pursue it right now.

      Thanks, wt

      Thank you.

    13. iritkatriel
      closed this as not plannedon Oct 29, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      3.7 (EOL)end of lifeend of lifetopic-IO

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

        You are visitor 01402503 — GeezerVison does not store the pages you look up.
        Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.