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 33693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T13:57:40+00:00 2026-05-10T13:57:40+00:00

Is it possible to capture Python interpreter’s output from a Python script? Is it

  • 0
  1. Is it possible to capture Python interpreter’s output from a Python script?
  2. Is it possible to capture Windows CMD’s output from a Python script?

If so, which librar(y|ies) should I look into?

  • 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. 2026-05-10T13:57:41+00:00Added an answer on May 10, 2026 at 1:57 pm

    If you are talking about the python interpreter or CMD.exe that is the ‘parent’ of your script then no, it isn’t possible. In every POSIX-like system (now you’re running Windows, it seems, and that might have some quirk I don’t know about, YMMV) each process has three streams, standard input, standard output and standard error. Bu default (when running in a console) these are directed to the console, but redirection is possible using the pipe notation:

    python script_a.py | python script_b.py 

    This ties the standard output stream of script a to the standard input stream of script B. Standard error still goes to the console in this example. See the article on standard streams on Wikipedia.

    If you’re talking about a child process, you can launch it from python like so (stdin is also an option if you want two way communication):

    import subprocess # Of course you can open things other than python here :) process = subprocess.Popen(['python', 'main.py'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) x = process.stderr.readline() y = process.stdout.readline() process.wait() 

    See the Python subprocess module for information on managing the process. For communication, the process.stdin and process.stdout pipes are considered standard file objects.

    For use with pipes, reading from standard input as lassevk suggested you’d do something like this:

    import sys x = sys.stderr.readline() y = sys.stdin.readline() 

    sys.stdin and sys.stdout are standard file objects as noted above, defined in the sys module. You might also want to take a look at the pipes module.

    Reading data with readline() as in my example is a pretty naïve way of getting data though. If the output is not line-oriented or indeterministic you probably want to look into polling which unfortunately does not work in windows, but I’m sure there’s some alternative out there.

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

Sidebar

Ask A Question

Stats

  • Questions 63k
  • Answers 63k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Your best bet might be to use adplus to capture… May 11, 2026 at 10:21 am
  • added an answer For some good short code examples, check this Design Patterns… May 11, 2026 at 10:21 am
  • added an answer I would suggest re-asking this question on the apple developer… May 11, 2026 at 10:21 am

Related Questions

Is it possible to capture Python interpreter's output from a Python script? Is it
I was just wondering if it is possible to capture the output of a
Is it possible to skip a couple of characters in a capture group in
Is it possible to run an external process from Perl, capture its stderr, stdout
Is it possible, or does anyone know the best way to capture MSN chats?
Is it possible to use an image captured with the iPhone's camera as a
It seems that it is impossible to capture the keyboard event normally used for
Is it possible to configure xampp to serve up a file outside of the
Is it possible to use a flash document embedded in HTML as a link?
Is it possible to access an element on a Master page from the page

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.