I am using Inline 0.44, Inline::Python 0.22, Python 2.4.1 and perl 5.8.4
on a recent debian install (I didn't do the install myself, but I can
find out more info about it if that's pertinent). When I return an
number from python and then pass it back into python, I get a string.
Is this expected behavior? Is there a way around it besides lots of
boilerplate code (either of the "pyfunc(pynum() + 0)" or of the "def
pyfunc(x): x = int(x)" type)?
Here's an example of the behavior I am talking about:
$ cat example.pl
#!/usr/bin/env perl
printvar(1.0);
printvar("1.0" + 1);
printvar(pyincrement(3.1) + 0.2);
print "This one is the problem: ";
printvar(pyincrement(3.1));
use Inline Python => <<'END_OF_PYTHON_CODE';
def pyincrement(n):
return n + 1
def printvar(v):
print repr(v), str(type(v))
END_OF_PYTHON_CODE
$ ./example.pl
1.0 <type 'float'>
2 <type 'int'>
4.2999999999999998 <type 'float'>
This one is the problem: '4.1' <type 'str'>
Can anyone shed some light on what is going on?
Thanks,
Eli