sbc has asked for the wisdom of the Perl Monks concerning the following question:

Hello!

I have a python class and its functions, that I wish to use in perl. But do not know how to. I do not want to call a python.py script(like, using a system call). Instead, i want to be able to use the following:

with classname as cname: cname.startup() cname.process(<args>) cname.shutdown()
in my perl script. I read about cpan Inline possibility, but do not want to install any pkgs. Any suggestion in this regard will help! Thanks.

Replies are listed 'Best First'.
Re: Embedding python objects in perl
by runrig (Abbot) on May 17, 2013 at 22:47 UTC
    ...but do not want to install any pkgs.

    Have somebody else install Inline::Python. Or rewrite the python in perl.

Re: Embedding python objects in perl
by davido (Cardinal) on May 18, 2013 at 00:12 UTC

    If you want to execute Python code within a Perl script, but don't want to call the Python script using a system call, and don't want to use any modules such as Inline::Python, you're asking that the Perl interpreter be capable of also interpreting Python natively.


    Dave

Re: Embedding python objects in perl
by thomas895 (Deacon) on May 18, 2013 at 03:13 UTC

    Don't want to install from CPAN? That's unfortunate, since CPAN is the very reason Perl is so good. Ah well, suit yourself...

    What you could do, however, is use the C API of both Python and Perl, and somehow "glue" them together. This will probably take you several months, so good luck and see you then.

    ~Thomas~ 
    "Excuse me for butting in, but I'm interrupt-driven..."
      Thank you for all your responses, helped me confirm that I was not leaving out any alternative solution. Thanks again for your time.
        Thank you for all your responses, helped me confirm that I was not leaving out any alternative solution. Thanks again for your time
Re: Embedding python objects in perl
by Anonymous Monk on May 17, 2013 at 23:16 UTC

    in my perl script. I read about cpan Inline possibility, but do not want to install any pkgs. Any suggestion in this regard will help! Thanks.

    Like, write it in python

Re: Embedding python objects in perl
by ambrus (Abbot) on May 21, 2013 at 11:35 UTC

    Spawn a separate python process, communicate with it in whatever way works in your case, such as writing out your input data to a file which your python script reads then have the python script write back a file that you read back in your perl script.