Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 92c0199308d7e61f719c4ecfa84d4ea2 > files > 26

php-python-0.8.0-7mdv2009.1.i586.rpm

--TEST--
Python: python_call()
--SKIPIF--
<?php if (!extension_loaded('python')) die("skip\n");
--FILE--
<?php

$py = <<<EOT
def Test(n):
    l = [1, 2, 3]
    l.append(n)
    return l
EOT;

# Execute the python code (in the __main__ module)
var_dump(python_exec($py));
echo "\n";

# Execute it the simple way.
var_dump(python_exec('Test(4)'));
echo "\n";

# Execute it the more interesting way.
var_dump(python_call('__main__', 'Test', 4));
echo "\n";

--EXPECT--
bool(true)

bool(true)

object(Python <type 'list'>)#1 (4) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
  [3]=>
  int(4)
}