The python print() will only print its arguments like a tuple after this .py is CPython-compiled into a .so and being imported. How can it behave like it is a normal py file?
The scenarios is like this. Here is a function output()
defined in mod4.py:
def output(a, b):
print(a, b, str(a)+str(b))
I use following main.py
to call output()
:
import mod4
mod4.output(2, 3)
the output will be like:
2 3 23
Then I compile mod4.py using CPython, by editing a setup.py like:
from distutils.core import setup
from Cython.Build import cythonize
setup(name="mod4.app", ext_modules=cythonize("mod4.py"))
and execute python setup.up build_ext --inplace
in command line, which in turn generates mod4.cpython-37m-darwin.so
. Then main.py
will output like:
(2, 3, '23')
it looks just like a tuple of the arguments of print().
The version of python is 3.7.4,
$ python --version
Python 3.7.4
How can I get output()
in .so outputs just like it in .py?