Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6020167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:31:43+00:00 2026-05-23T03:31:43+00:00

Two (related?) questions here. I was trying to write a program to start an

  • 0

Two (related?) questions here.

I was trying to write a program to start an external process, and then simultaniouly read from stdout and write to stdin. Everything seemed to be working, however the process was not responding to the data sent to its stdin pipe. Do you know why this would be?(1)

This second question is solved now.

I wrote two testing scripts, the first was as such:

# recv.py
while True:
    print(input())

The second was designed to call the other using Popen, the give it some arbitrary input:

# send.py
recv = subprocess.Popen(["python", "recv.py"], stdin=subprocess.PIPE)
recv.stdin.write(b"Hello\n")
recv.stdin.write(b"World.\n")

This is what I got when I ran it:

skyler@pro:testing$ python send.py 
skyler@pro:testing$ Traceback (most recent call last):
  File "recv.py", line 30, in <module>
    main()
  File "recv.py", line 26, in main
    print(input())
  File "<string>", line 1, in <module>
NameError: name 'Hello' is not defined

It looks like for whatever reason the result of input() is being treated like part of the line, instead of a string, indeed when I set a variable Hello in recv.py, it printed the contents of Hello. Why is this happening?(2)

I’m running python 3.1.2 on Mac OSX.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:31:44+00:00Added an answer on May 23, 2026 at 3:31 am

    What you’re seeing is the expected behaviour of Python 2.x’s input() function, which takes a line from sys.stdin (like raw_input()) and then evaluates it as Python code. It’s generally a bad idea to use input() in Python 2.x 🙂 In Python 3.x, input() was removed and raw_input() was renamed to input(), which may be why you’re confused about what it does.

    You’re not executing Python 3.x, even though you may have it installed. The python command is probably (hopefully!) still the system-installed Python 2.x. Try running it with python3 or python3.1 instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here are two questions related to modifying the data source for strongly typed dataset
Here are two different questions but I think they are related. When using Git,
I've been looking through related LINQ questions here trying to figure this one out,
Okay, these two related questions are in reference to Railscast #21 : I'm having
I have tried solving this problem by posting other related questions here that focused
After reviewing the related questions, none of them seem to address mine, so here
Somewhat related to this question . I'm trying to create a window with two
I have two questions, both related to the same view: so there is view
I have two related qestions on the code included below 1) I am trying
I have two related classes which share a common interface and are both stored

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.