Perl inside Python?

There is a Perl library with which I would like to access from Python. How can i use it?

FYI, NCleaner Software . I would like to use it from Python to convert an HTML string to text. (Yes, I know about aaronsw Python html2text. NCleaner is better because it removes the boiler room.)

I donโ€™t want to run the Perl program as a script and call it repeatedly because it has an expensive initial load time, and I call it many times.

+6
python perl text-mining
source share
1 answer

pyperl provides a perl implementation for python, but honestly, this is not the way I would go. Roboto's second suggestion is to write a script that runs NCleaner (either processes from stdin to stdout, or works on temporary files, whichever is more appropriate), and runs it as a subprocess.

Or, since I see on the NCleaner page that it has a C implementation, use whatever means Python has to bind to the C code, and write a Python module that completes the implementation of NCleaner C. Then in the future, answer the NCleaner call from Python will just be "here, use this module."

Footnote: Inline :: Python is better code than pyperl, and I would suggest using it instead, but it only supports that Python accesses Perl when Python is called with Perl in the first place - the ability to embed Perl in Python is specified as possible future function, but it has been so since 2001, so do not hold your breath.

+12
source share

All Articles