From 63df7b07c5dffdce7af7647963f799d346ab77a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quinten=20Prei=C3=9F?= Date: Mon, 27 May 2024 17:50:30 +0200 Subject: [PATCH 1/2] Added global option to disable 'Python:' prefix in show --- src/Core/Py.jl | 10 +++++++++- src/PythonCall.jl | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Core/Py.jl b/src/Core/Py.jl index 396b39d8..47c03f23 100644 --- a/src/Core/Py.jl +++ b/src/Core/Py.jl @@ -174,6 +174,14 @@ function Base.show(io::IO, x::Py) end end +printPyPrefix::Bool = true + +function printPyPrefix!(printPrefix::Bool=true) + global printPyPrefix = printPrefix + return printPyPrefix +end +export printPyPrefix! + function Base.show(io::IO, ::MIME"text/plain", o::Py) if pyisnull(o) str = "NULL" @@ -184,7 +192,7 @@ function Base.show(io::IO, ::MIME"text/plain", o::Py) compact = get(io, :compact, false)::Bool multiline = '\n' in str prefix = hasprefix ? compact ? "Py:$(multiline ? '\n' : ' ')" : "Python:$(multiline ? '\n' : ' ')" : "" - print(io, prefix) + printPyPrefix && print(io, prefix) h, w = displaysize(io) if get(io, :limit, true) h, w = displaysize(io) diff --git a/src/PythonCall.jl b/src/PythonCall.jl index fdd1774f..65869894 100644 --- a/src/PythonCall.jl +++ b/src/PythonCall.jl @@ -27,7 +27,7 @@ end for k in [:python_executable_path, :python_library_path, :python_library_handle, :python_version] @eval using .C: $k end -for k in [:pynew, :pyisnull, :pycopy!, :getptr, :pydel!, :unsafe_pynext, :PyNULL, :CONFIG] +for k in [:pynew, :pyisnull, :pycopy!, :getptr, :pydel!, :unsafe_pynext, :PyNULL, :CONFIG, :printPyPrefix!] @eval using .Core: $k end for k in [:pyconvert_add_rule, :pyconvert_return, :pyconvert_unconverted, :PYCONVERT_PRIORITY_WRAP, :PYCONVERT_PRIORITY_ARRAY, :PYCONVERT_PRIORITY_CANONICAL, :PYCONVERT_PRIORITY_NORMAL, :PYCONVERT_PRIORITY_FALLBACK] From 83d0a63fea9b622fb073d892c5d0a537ac8e7c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quinten=20Prei=C3=9F?= Date: Mon, 27 May 2024 17:56:15 +0200 Subject: [PATCH 2/2] Removed type declaration on global variable, since not supported in older versions of julia --- src/Core/Py.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/Py.jl b/src/Core/Py.jl index 47c03f23..9e5fb425 100644 --- a/src/Core/Py.jl +++ b/src/Core/Py.jl @@ -174,7 +174,7 @@ function Base.show(io::IO, x::Py) end end -printPyPrefix::Bool = true +printPyPrefix = true function printPyPrefix!(printPrefix::Bool=true) global printPyPrefix = printPrefix