JuliaPy / JuliaPy/PythonCall.jl

print versus println to stdout

未關閉
#290 7 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Julia
星號
1.1k
分支
86
平均合併
1 天 22 小時
30 天內合併 PR
3

描述

In transitioning from PyCall.jl, I was just trying to confirm that the stdout forwarding worked similarly and came across an example I found puzzling.

```
@py begin
import numpy as np
a = np.zeros(10)
println(a)
end
```

Completes and prints as normal

```
@py begin
import numpy as np
a = np.zeros(10)
print(a)
end
```

Fails and gives the error "Python: TypeError: memoryview: a bytes-like object is required, not 'str'".

I am just trying to reproduce the functionality I had before with py_str and using the `pyimport("sys")."stdout" = PyTextIO(stdout)`. My concern is that sometimes I want to import and run python packages that are doing print and not println and would like that to work without me having to edit them. Is this expected behavior or have I done something wrong/there is a better way to be going about this?

```
Julia Version 1.8.2
Commit 36034abf260 (2022-09-29 15:21 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
[6099a3de] PythonCall v0.9.12
```

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。