Subject: | How to pass booleans to Python functions |
Date: | Sat, 21 Dec 2013 18:02:28 +0100 |
To: | bug-Inline-Python [...] rt.cpan.org |
From: | Ronald Hecht <ronald.hecht [...] gmx.de> |
From Perl I am trying to pass a real Boolean value to Python. I found
that this should be supported by the current version. I was trying to
create a Python boolean this way:
my $true = Inline::Python::Boolean->new(1);
But passing this value to Python does not work. Printing received value
does not show "True" but
<perl object: 'main::Inline::Python::Boolean::'>
On the other hand it is possible to get a Boolean from Python and pass
it back from Perl to Python. As a workaround, I wrote a small Python
function that gives me a Python Boolean to Perl, that can be used for
function calls.
Strangely the $true value above and the Python returned Boolean show the
same correct class (by using 'ref $true') Inline::Python::Boolean.
So, How do I correctly pass Python Booleans to perl like
a_python_function(Inline::Python::Boolean->new(1));