Calling Python code from inside php

Diez B. Roggisch deets at
Wed Apr 23 21:35:43 CEST 2008

> A simple yet dangerous and rather rubbish solution (possibly more of a
> hack than a real implementation) could be achieved by using a
> technique described above:
> <?php
>         echo exec('python');
> ?>

What is rubbish about that - except from the obvious cleansing of input 
variables that has to take place? Python has a whole module dedicated to 
that rubbish, called subprocess.

> I would look into pyphp though. This method has so many issues
> attached to it it's hardly worth bothering with.
> I'm with Nick when I say why on earth are you needing to call Python
> from within PHP as opposed to using only Python or only PHP?

While I certainly prefer to use Python wherever I can, that does not 
mean that there aren't cases where legacy systems or other constraints 
make this impossible. If I have e.g. a type3-based website - "how on 
earth" should I replace that with Python (without wasting a lot of time)?


More information about the Python-list mailing list