Skip to main content.
Enero 21st, 2007  español 

Calling Perl functions from Python

Computer Science Programming

I’m currently working on a project and need to call old Perl functions from Python (until the perl code is refactorized and translated to python).

A friend of mine told me about PyPerl, but we found it’s currently unmaintained. :(

Suppose you have a perl module, named mylib.pl, which have a function like:

sub myfunc
{
my ($a, $b) = @_;
...
...

return result;
}

We wanted to be able to call myfunc function from python, without having to rewrite it.
So I managed to create a python module to wrap perl functions in python, using python decorators. With it, you can call perl functions this way:

import perlfunc

@perlfunc
@perlreq('mylib.pl')
def myfunc(a, b):
    pass

This would call the perl function myfunc (defined in library mylib.pl) using a and b as parameters. Lists (and arrays as list of lists) and dictionaries can be passed as parameters (they are conveniently converted to perl).

It seems to work very well. :)
It’s licensed GPL, and you can download it from here: perlfunc.py

Posted by Boriel as Computer Science, Programming at 10.44 pm

Rate This Post: 1 Stars2 Stars3 Stars4 Stars5 Stars
2 Votes | Average: 4 out of 52 Votes | Average: 4 out of 52 Votes | Average: 4 out of 52 Votes | Average: 4 out of 52 Votes | Average: 4 out of 5 (2 votes, average: 4 out of 5)
5 Comments »
Enero 5th, 2007  español 

They’re arriving tonight…

Pictures

In the previous post I mentioned The Three Wise Men.
Three Wise Men
They’re arriving tonight… Have you behaved yourselves?

Posted by Boriel as Pictures at 7.40 pm

Rate This Post: 1 Stars2 Stars3 Stars4 Stars5 Stars
3 Votes | Average: 5 out of 53 Votes | Average: 5 out of 53 Votes | Average: 5 out of 53 Votes | Average: 5 out of 53 Votes | Average: 5 out of 5 (3 votes, average: 5 out of 5)
2 Comments »
Enero 1st, 2007  español 

Don’t buy things you can’t afford

An advise for americans (due to its simplicity), and sooner for europeans. Comic actors play a funny take, Don’t buy things you can’t afford.

And here, in Spain, we still have The Magic Kings the Three Wise Men, on Jan the 6th… (Yes, Santa Claus, the revenge of consumerism).

Via meneame

Happy 2007. ;-)

Posted by Boriel as Vídeo at 11.10 am

Rate This Post: 1 Stars2 Stars3 Stars4 Stars5 Stars
No Ratings Yet
1 Comment »