JuliaPy / JuliaPy/PythonCall.jl

print versus println to stdout

Abierto
#290 7 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Julia
Estrellas
1.1k
Forks
86
Merge medio
1 d 22 h
PR fusionados (30 d)
3

Descripción

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
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Start by reproducing the two @py examples with PythonCall v0.9.12, focusing on stdout forwarding and the PyTextIO setup described in the issue. Trace how print and println are handled, then verify that Python packages using print forward output without the reported memoryview TypeError.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
julia, python
Área
api, backend
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.