Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

why sys.stdout returned null #370

Copy link
Copy link
@yagweb

Description

@yagweb
Issue body actions

Environment

  • Pythonnet version: 2.2.2 (.NET 4, x64)
  • Python version: 3.5
  • Operating System: Windows 10

Details

Python is embedded in my .NET application using pythonnet. I found the output of the print statement in a python script is not showing on the screen until a "sys.stdout.flush()" called. I don't known how to redirect sys.stdout in .NET.
In order to call the flush() method directly in .NET, I tried

dynamic sys = PythonEngine.ImportModule("sys");
var stdout= sys.GetAttr("stdout"); // returns None

and both sys.stdout and the variable stdout returned are None here.

In python, I tried

import sys
print(getattr(sys, 'stdout'))

and it outputs a _io.TextIOWrapper object.

Why sys.stdout returned null here? How to make the output of python print statement show automatically?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.