python-shell icon indicating copy to clipboard operation
python-shell copied to clipboard

Can I disable splitting line of result?

Open Clarit7 opened this issue 3 years ago • 4 comments

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:

Clarit7 avatar May 11 '21 19:05 Clarit7

You found a bug, congrats! 🎉 🐛

It looks like this is a regression - until I fix it try using [email protected]

Almenon avatar May 12 '21 03:05 Almenon

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

Clarit7 avatar May 12 '21 07:05 Clarit7

The new line issue is a bug.

Almenon avatar May 12 '21 15:05 Almenon

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

Clarit7 avatar May 12 '21 17:05 Clarit7