Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I disable splitting line of result? #242

Open
Clarit7 opened this issue May 11, 2021 · 4 comments
Open

Can I disable splitting line of result? #242

Clarit7 opened this issue May 11, 2021 · 4 comments

Comments

@Clarit7
Copy link

Clarit7 commented May 11, 2021

The Question:

First of all, thanks for making awesome package, but I got stuck in a small problem.
Can I disable splitting line feature?

For example, I want python code result is printed like this:

print("aa\n\n\nbb\n\ncc\n\dd")
>> aa


bb

cc
dd

However, the result was like this:

print("aa\n\n\nbb\n\ncc\n\dd")
>> aa
bb
cc
dd

After few tries, I realized newline indicators are splitting lines and returned result is list of string without newline indicators.
Can you tell me how can I get a raw result without removed newline symbols? Or if the feature is not implemented, do you have any plans for adding the disabling newline feature?

In addition, I tried it on binary mode but function always returns null.

The input was a single line string and I converted it to Buffer like as follows:

const input = "import numpy as np\n\nprint(np.array([1, 2]))\nprint(123)"
const buf = Buffer.from(input, 'utf8');

PythonShell.runString(buf, options, function (err, results) { ...

Have I done something wrong?

Any relevant python/javascript code:

@Almenon
Copy link
Collaborator

Almenon commented May 12, 2021

You found a bug, congrats! 🎉 🐛

It looks like this is a regression - until I fix it try using python-shell@2.0.3

@Clarit7
Copy link
Author

Clarit7 commented May 12, 2021

Thanks for answering :) Which one is a bug? Continuous newline symbol not working problem or input buffer not working problem?

@Almenon
Copy link
Collaborator

Almenon commented May 12, 2021

The new line issue is a bug.

@Clarit7
Copy link
Author

Clarit7 commented May 12, 2021

I see. After regression to version 2.0.3, then the function returns perfect result what I expected. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants