Discussion:
Inline::Python but vice versa
Konovalov, Vadim
2014-12-13 12:44:22 UTC
Permalink
Dear Stefan,
First of all, thank you for maintaining such a useful module,

All other supporters, thank you to make the really nice module possible :)

A hopefully simple question,
Is it possible to use Perl from Python?

All I want to do - to script some editor with perl, whereas only python scripting is available...
Of course my editor-api calls will be issued with Inline::Python or something like that.

Interested in solutions that are not only theoretical but verified in practice :)

Thanks in advance,
Vadim.
Stefan Seifert
2014-12-13 13:09:32 UTC
Permalink
Hi Vadim,
Post by Konovalov, Vadim
A hopefully simple question,
Is it possible to use Perl from Python?
All I want to do - to script some editor with perl, whereas only python
scripting is available... Of course my editor-api calls will be issued with
Inline::Python or something like that.
You mean your editor is written in Perl and you want to allow for your users
to script it in Python and these Python scripts should be able to call back
into Perl to for example call API methods?

Yes, that's exactly what my use case looks like and probably what's tested
best. You could for example pass an Editor object as parameter to your Python
script and the script may use it like it was a plain normal Python object and
call methods on it.

https://metacpan.org/pod/distribution/Inline-Python/Python.pod#Using-Perl-inside-Python-inside-Perl may give you additional pointers to what's possible.

Please feel free to ask any questions that may come up on how to integrate
Python scripting. I do have quite some experience on how to bridge these two
languages and am happy to help.

Regards,
Stefan
Konovalov, Vadim
2014-12-13 13:39:36 UTC
Permalink
Post by Stefan Seifert
Post by Konovalov, Vadim
A hopefully simple question,
Is it possible to use Perl from Python?
All I want to do - to script some editor with perl, whereas only
python scripting is available...
You mean your editor is written in Perl and you want to
allow for your users to script it in Python and these
Python scripts should be able to call back into Perl to for
example call API methods?
No,
There is existing editor (e.g. sublime or maybe KIG - KDE 2D-geometry)
which is scripted by python already,
but I want to use Perl from there.

What I actually want - is a module inside vanilla python that allows me to run Perl, ...

I've read "Using-Perl-inside-Python-inside-Perl" but seems to me this isn't exactly what helps me in this situation.
Yet I already used Perl-inside-Python-inside-Perl :)
The cool stuff possible with Inline::Python is that I can write fully functional application with Qt, whereas Qt used via Python (perlQt are all stale) and I was able to do this way -

use Inline Python => <<'EOS';
.......
self.pushButton = QtGui.QPushButton("&Foo Button")
.....
self.pushButton.clicked.connect(perl.qwerty);
......
EOS

my $app = get_app();
my $w = init_some_window();

sub qwerty {
$w->{pushButton}->setText('['.$w->{pushButton}->text().']');
}

$app->exec_();

Really really really cool stuff :)

Have a nice day,
Vadim.

Loading...