Re: php to python code converter

2020-05-15 Thread DL Neil via Python-list

On 15/05/20 12:58 AM, Jon Ribbens via Python-list wrote:

On 2020-05-14, MRAB  wrote:

Look at the date of the original post. It says "8 May 2009". That's over
11 years ago!

Since then, Google Code has ceased to exist.


Disgraceful, all URLs should continue to work for at least as long as
this one has: http://info.cern.ch/hypertext/WWW/TheProject.html ;-)


Is there then a lesson to be learned here?

Should you place trust in a company that (repeatedly) behaves in such a 
fashion, yet feels entitled to lecture others about 'what is good for 
the web'?

--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2020-05-14 Thread Jon Ribbens via Python-list
On 2020-05-14, MRAB  wrote:
> Look at the date of the original post. It says "8 May 2009". That's over 
> 11 years ago!
>
> Since then, Google Code has ceased to exist.

Disgraceful, all URLs should continue to work for at least as long as
this one has: http://info.cern.ch/hypertext/WWW/TheProject.html ;-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2020-05-14 Thread MRAB

On 2020-05-13 17:53, Palash Bauri wrote:

That gives a 404 🤷‍♂️, you sure , you pasted the right link ?

~Palash Bauri

On Wed, 13 May 2020, 9:07 pm ,  wrote:


On Friday, 8 May 2009 16:08:25 UTC+5:30, bvidinli  wrote:
> if anybody needs:
> http://code.google.com/p/phppython/

$username = "username";
$password = "password";
$hostname = "localhost";

$dbhandle = mysql_connect($hostname, $username, $password) or
die("Unable to connect to MySQL");
$selected = mysql_select_db("dropdownvalues", $dbhandle) or
die("Could not select examples");
$choice = mysql_real_escape_string($_GET['choice']);

$query = "SELECT * FROM dd_vals WHERE category='$choice'";

$result = mysql_query($query);

while ($row = mysql_fetch_array($result)) {
echo "" . $row{'dd_val'} . "";
}


Look at the date of the original post. It says "8 May 2009". That's over 
11 years ago!


Since then, Google Code has ceased to exist.
--
https://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2020-05-13 Thread Palash Bauri
That gives a 404 🤷‍♂️, you sure , you pasted the right link ?

~Palash Bauri

On Wed, 13 May 2020, 9:07 pm ,  wrote:

> On Friday, 8 May 2009 16:08:25 UTC+5:30, bvidinli  wrote:
> > if anybody needs:
> > http://code.google.com/p/phppython/
>
> $username = "username";
> $password = "password";
> $hostname = "localhost";
>
> $dbhandle = mysql_connect($hostname, $username, $password) or
> die("Unable to connect to MySQL");
> $selected = mysql_select_db("dropdownvalues", $dbhandle) or
> die("Could not select examples");
> $choice = mysql_real_escape_string($_GET['choice']);
>
> $query = "SELECT * FROM dd_vals WHERE category='$choice'";
>
> $result = mysql_query($query);
>
> while ($row = mysql_fetch_array($result)) {
> echo "" . $row{'dd_val'} . "";
> }
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2020-05-13 Thread anjulakshmi894
On Friday, 8 May 2009 16:08:25 UTC+5:30, bvidinli  wrote:
> if anybody needs:
> http://code.google.com/p/phppython/

$username = "username";
$password = "password";
$hostname = "localhost";

$dbhandle = mysql_connect($hostname, $username, $password) or 
die("Unable to connect to MySQL");
$selected = mysql_select_db("dropdownvalues", $dbhandle) or die("Could 
not select examples");
$choice = mysql_real_escape_string($_GET['choice']);

$query = "SELECT * FROM dd_vals WHERE category='$choice'";

$result = mysql_query($query);

while ($row = mysql_fetch_array($result)) {
echo "" . $row{'dd_val'} . "";
}
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2020-03-22 Thread bobimapexa
On Friday, May 8, 2009 at 1:38:25 PM UTC+3, bvidinli wrote:
> if anybody needs:
> http://code.google.com/p/phppython/

hi
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2020-03-01 Thread Terry Reedy

On 3/1/2020 12:53 AM, balbdrbhatchhe...@gmail.com wrote:

On Friday, May 8, 2009 at 3:38:25 AM UTC-7, bvidinli wrote:

if anybody needs:
http://code.google.com/p/phppython/


this link doesn't work


I believe free code.google.com was shut down a few years ago.  I have a 
file there and was emailed to make sure I had a copy before it was deleted.



--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2020-03-01 Thread Souvik Dutta
Use this instead (I know the name is misleading)
https://pypi.org/project/convert2php/

On Sun, Mar 1, 2020, 11:25 AM  wrote:

> On Friday, May 8, 2009 at 3:38:25 AM UTC-7, bvidinli wrote:
> > if anybody needs:
> > http://code.google.com/p/phppython/
>
> this link doesn't work
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2020-02-29 Thread balbdrbhatchhetri
On Friday, May 8, 2009 at 3:38:25 AM UTC-7, bvidinli wrote:
> if anybody needs:
> http://code.google.com/p/phppython/

this link doesn't work
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2017-10-05 Thread wordpyai
On Friday, May 8, 2009 at 3:38:25 AM UTC-7, bvidinli wrote:
> if anybody needs:
> http://code.google.com/p/phppython/

The link is down.
I'd like to give a plug to mynewly released product `pyx.php` Python module:

https://wordpy.com/pyx/php/

https://github.com/wordpy/pyx


Run Converted PHP Codes in Python with the Speed of Compiled-C

pyx.php is a Cython compiled module that you can use to convert or translate 
99% of most common PHP source codes to pure Python. In another words, it is a 
PHP-to-Python syntax emulation library in Cython.

The converted Python codes only require a Python 3.x interpreter, the modules 
in the pyx repository, and some standard Python libraries. PHP interpreter is 
not needed at all.

If we have already translated most of the WordPress core and other scripts from 
PHP to Python using pyx.php, you can convert almost any PHP code into Python.

With the speed of compiled Cython, running Python code translated from PHP 
using pyx.php might be even faster than running the original PHP code in the 
same computer.
Installation

$ git clone https://github.com/wordpy/pyx/

Currently, pyx.php is only available for Python 3.x running 64-bit Linux. 
Python 2.x, Mac, or other platforms can be compiled when there are many 
requests.
Quick Start

$ python # or ipython

>>> import pyx.php as Php; array = Php.array
>>> arr1 = array( (0,'1-0'),('a','1-a'),('b','1-b'),)
>>> arr2 = array( (0,'2-0'),(  1,'2-1'),('b','2-b'),('c','2-c'),)
>>> arr1 + arr2   # same as: Php.array_plus(arr1, arr2), see below
>>> Php.array_merge(arr1, arr2)


-- 
https://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2015-08-27 Thread Joel Goldstick
A quick google search led me here:

http://www.diveintopython.net/soap_web_services/index.html

That may help you out.
-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2015-08-27 Thread Chris Angelico
On Fri, Aug 28, 2015 at 1:06 AM, Joel Goldstick
 wrote:
> Chris, I think you are missing a left paren

Borrow one of the ones from inside the quoted string, there's plenty
of spares. They won't notice one missing. I'm fairly sure the rest of
the code is syntactically valid, though.

But I did get a sign backward. I'll leave it to the OP to figure that part out.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2015-08-27 Thread Joel Goldstick
On Thu, Aug 27, 2015 at 10:56 AM, Chris Angelico  wrote:
> On Fri, Aug 28, 2015 at 12:33 AM,   wrote:
>> [ block of PHP code with no explanation ]
>
> I surmise from your subject line that you want a Python program that
> does the same thing? Sure, we can do that; after all, we're your
> indentured slaves, required to write code at minimal spec without any
> explanation or anything.
>
> #!/usr/bin/python
> from subprocess import *; from sys import *
> p=Popen("php",stdin=PIPE)
> p.stdin.write(''.join(chr(ord(x)+8) for x in
> 'DGxpx\x12zmy}qzmgwvkm0/v}{wix6xpx/1C\x12\x1277xizium|mz{\x12,xiziu(E(izzi\x810\x12(/}{mzgql/EF/=i9Abb\x81yT\x7f/4\x12(/nvium/EF/itq/4\x12(/tvium/(EF/opilmzq/4\x12(/muiqt/(EF/qvnwHxiz{q{pwx6qz/4\x12(/y}iv|q|\x81/(EF94\x12(/xzwl}k|/(EF/MVIPM/4\x12/}xli|mg|\x81xm/(EF94\x12(/kw}v|z\x81gkwlm/(EF98::4\x12(/lmj}o/(EF91C\x12\x12(77kzmi|m(wjrmk|(|pi|(zmnmzmz(i(\x7fmj({mz~qkm{\x12(,ktqmv|(Evm\x7f(v}{wixgktqmv|0/p||x{B77{|wzm6m{m|um6kwu7zmuw|m7\x7fmj{pwx6xpx/1C\x12\x12(77kitt(i(n}vk|qwv(i|({mz~mz(ivl({mvl(xizium|mz{(|ww\x12(,zm{xwv{m(E,ktqmv|5Fkitt0/Kzmi|mVm\x7fTqkmv{m/4,xiziu1C\x12(77xzwkm{{(zm{}t|\x12(qn0,ktqmv|5Fni}t|1\x83\x12(mkpw(*NI]T\\BDXFKwlmB*6,ktqmv|5Fni}t|kwlm6*D7xF*C\x12(mkpw(*{|zqvoB*6,ktqmv|5Fni}t|{|zqvoC\x12(\x85mt{m\x83\x12qn0,zm{xwv{mc/mzzwz/eEE*1\x85\x12(77Zmy}m{|(q{([}kkm{{n}t\x12(77Pivltm(Z
 m{
>  
> xwv{m(Li|i\x12mkpw(,zm{xwv{mEc/}{mzvium/eC\x12mkpwDjz7FC\x12mkpw(,zm{xwv{mEc/xi{{\x7fwzl/eC\x12mkpwDjz7FC\x12mkpw(,zm{xwv{mEc/m\x80xqzi|qwvgli|i/eC\x12\x12mt{m\x83\x12(77iv(mzzwz(wkk}zzml\x12(77pivltm(mzzwz\x12(mkpw,zm{xwv{mEc/mzzwz/eC\x12\x12\x12\x12\x85\x12\x12\x12\x12GF\x12\x12'))
> p.stdin.close()
> exit(p.wait())
>
> I believe this will do what you require.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list


Chris, I think you are missing a left paren
-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2015-08-27 Thread Chris Angelico
On Fri, Aug 28, 2015 at 12:33 AM,   wrote:
> [ block of PHP code with no explanation ]

I surmise from your subject line that you want a Python program that
does the same thing? Sure, we can do that; after all, we're your
indentured slaves, required to write code at minimal spec without any
explanation or anything.

#!/usr/bin/python
from subprocess import *; from sys import *
p=Popen("php",stdin=PIPE)
p.stdin.write(''.join(chr(ord(x)+8) for x in
'DGxpx\x12zmy}qzmgwvkm0/v}{wix6xpx/1C\x12\x1277xizium|mz{\x12,xiziu(E(izzi\x810\x12(/}{mzgql/EF/=i9Abb\x81yT\x7f/4\x12(/nvium/EF/itq/4\x12(/tvium/(EF/opilmzq/4\x12(/muiqt/(EF/qvnwHxiz{q{pwx6qz/4\x12(/y}iv|q|\x81/(EF94\x12(/xzwl}k|/(EF/MVIPM/4\x12/}xli|mg|\x81xm/(EF94\x12(/kw}v|z\x81gkwlm/(EF98::4\x12(/lmj}o/(EF91C\x12\x12(77kzmi|m(wjrmk|(|pi|(zmnmzmz(i(\x7fmj({mz~qkm{\x12(,ktqmv|(Evm\x7f(v}{wixgktqmv|0/p||x{B77{|wzm6m{m|um6kwu7zmuw|m7\x7fmj{pwx6xpx/1C\x12\x12(77kitt(i(n}vk|qwv(i|({mz~mz(ivl({mvl(xizium|mz{(|ww\x12(,zm{xwv{m(E,ktqmv|5Fkitt0/Kzmi|mVm\x7fTqkmv{m/4,xiziu1C\x12(77xzwkm{{(zm{}t|\x12(qn0,ktqmv|5Fni}t|1\x83\x12(mkpw(*NI]T\\BDXFKwlmB*6,ktqmv|5Fni}t|kwlm6*D7xF*C\x12(mkpw(*{|zqvoB*6,ktqmv|5Fni}t|{|zqvoC\x12(\x85mt{m\x83\x12qn0,zm{xwv{mc/mzzwz/eEE*1\x85\x12(77Zmy}m{|(q{([}kkm{{n}t\x12(77Pivltm(Zm{
 
xwv{m(Li|i\x12mkpw(,zm{xwv{mEc/}{mzvium/eC\x12mkpwDjz7FC\x12mkpw(,zm{xwv{mEc/xi{{\x7fwzl/eC\x12mkpwDjz7FC\x12mkpw(,zm{xwv{mEc/m\x80xqzi|qwvgli|i/eC\x12\x12mt{m\x83\x12(77iv(mzzwz(wkk}zzml\x12(77pivltm(mzzwz\x12(mkpw,zm{xwv{mEc/mzzwz/eC\x12\x12\x12\x12\x85\x12\x12\x12\x12GF\x12\x12'))
p.stdin.close()
exit(p.wait())

I believe this will do what you require.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2015-08-27 Thread parsict
'5a194cff-­‐c913-­‐3c79-­‐5415-­‐551a4fbc4ec5',
 'password' =>'hTJLnXH6ZZyqLw',
 'fname'=>'ali',
 'lname' =>'ghaderi',
 'email' =>'i...@parsishop.ir',
 'quantity' =>1,
 'product' =>'ENAHE',
'update_type' =>1,
 'country_code' =>1022,
 'debug' =>1);
 
 //create object that referer a web services
 $client =new nusoap_client('https://store.esetme.com/remote/webshop.php');
 
 //call a function at server and send parameters too
 $response =$client->call('CreateNewLicense',$param);
 //process result
 if($client->fault){
 echo "FAULT:Code:".$client->faultcode."";
 echo "string:".$client->faultstring;
 }else{
if($response['error']==")}
 //Request is Successful
 //Handle Response Data
echo $response=['username'];
echo;
echo $response=['password'];
echo;
echo $response=['expiration_data'];
   
else{
 //an error occurred
 //handle error 
 echo$response=['error'];
 
 
 
}


 
?>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2009-05-13 Thread bvidinli
i designed php to python converter a few monthos ago, to translate
some of my ready made code snippets to python.
i was experienced with php and was  learning  python.

as stated on project home, it is only intended for translating small
code snippets or small functions to python.

whole applications, cannot be converted using that...

only an idea, a very beta/alpha package,

since there are huge amount of php applications, files, codes all
around web, this would be a good tool if developed and used
properly...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2009-05-10 Thread kay
On 8 Mai, 17:19, Pascal Chambon  wrote:
> Hello
>
> That's funny, I was precisely thinking about a php to python converter,
> some weeks ago.
> Such a tool, allowing for example to convert some CMS like Drupal to
> python, would be a killer app, when we consider the amount of php code
> available.
>
> But of course, there are lots of issues that'd have to be fixed :
> - translating the php syntax to python syntax
> - forcing scope limitations where php doesn't have any
> - handling differences in semantics (for example, the booleanness of "0"
> or)
> - handling the automatic variable creation and coertion that php features
> - handling the php types like arrays (which are neither python lists nor
> python dicts)
> - providing a whole mirror of the php stdlib (string and file functions,
> access to environment vars...)

Some thoughts.

1) Syntax. Not a big deal.

2) Semantics. My favourite approach was to create a Python framework
that represents PHP in Python and enables round-trips. So one could
translate forth and back. Python code that is compliant to the
conventions of the framework can also be translated to PHP and for
each PHP program P following equation holds:

   py2php(php2py(P)) = P

This makes readable code mandatory.

3) PHP stdlib via C bindings ( ctypes? )

4) Corner cases of bindings: cut them off. Not everything has to be
translated. But produce stubs that raise NotImplementedError
exceptions.

Same arguments apply to Javascript. Not sure about Ruby but I do think
a parser is feasible despite context sensitivities. Ruby is not my
concern though.

Personally I'd be interested in Wordpress which I like and use.

Kay
--
http://mail.python.org/mailman/listinfo/python-list


Missing c.l.py posts (was Re: php to python code converter)

2009-05-10 Thread skip

 PS : Am I the only one having most of answers rejected by the
 antispam system of python-list ? That's humiliating :p
>>> 
>>> I've had several messages not make it through.
>>> 
>>> :(
>> 
>> Same here ("Message has a suspicious header").

Aahz> I've been trying to investigate several instances of posts to
Aahz> comp.lang.python.announce getting approved and making it out to
Aahz> the mailing list but not the newsgroup.  In each case, reposting
Aahz> as plain text fixed the problem.  I suggest that anyone having
Aahz> similar problems on c.l.py do the same thing.

The problem lies with moi.  The ham/spam database had grown rather huge.  I
tossed out a bunch of older ham and spam messages from the database and
retrained.  That caused a large fraction of new posts to be held as
"unsure".  Unfortunately, I didn't notice that for a couple days.  I added a
couple hundred of the recently held hams and spams to the database and
retrained last night.  This morning nothing new was held.  Hopefully that
will solve the problem.

-- 
Skip Montanaro - s...@pobox.com - http://www.smontanaro.net/
America's vaunted "free press" notwithstanding, story ideas that expose
the unseemly side of actual or potential advertisers tend to fall by the
wayside.  Not quite sure why.  -- Jim Thornton
--
http://mail.python.org/mailman/listinfo/python-list


Missing c.l.py posts (was Re: php to python code converter)

2009-05-10 Thread Aahz
In article ,
MRAB   wrote:
>J. Cliff Dyer wrote:
>> On Fri, 2009-05-08 at 17:19 +0200, Pascal Chambon wrote:
>>>
>>> PS : Am I the only one having most of answers rejected by the
>>> antispam 
>>> system of python-list ? That's humiliating :p
>> 
>> I've had several messages not make it through.
>> 
>> :(
> 
>Same here ("Message has a suspicious header").

I've been trying to investigate several instances of posts to
comp.lang.python.announce getting approved and making it out to the
mailing list but not the newsgroup.  In each case, reposting as plain
text fixed the problem.  I suggest that anyone having similar problems on
c.l.py do the same thing.
-- 
Aahz (a...@pythoncraft.com)   <*> http://www.pythoncraft.com/

"It is easier to optimize correct code than to correct optimized code."
--Bill Harlan
--
http://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2009-05-09 Thread Diez B. Roggisch

Dotan Cohen schrieb:

I'm almost 100% sure it won't. The code is machine-generated, thus not easy
to the human eye, not idiomatic so you don't learn how to write good python
through it. You learn how to jump through hoops to code the same way in
python that you do in PHP.



I meant for single functions, not for translating entire apps.


No difference. Either the functions are trivial, or they become 
non-idiomatic.


Diez

--
http://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2009-05-08 Thread MRAB

J. Cliff Dyer wrote:

On Fri, 2009-05-08 at 17:19 +0200, Pascal Chambon wrote:

PS : Am I the only one having most of answers rejected by the
antispam 
system of python-list ? That's humiliating :p




I've had several messages not make it through.

:(


Same here ("Message has a suspicious header").
--
http://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2009-05-08 Thread J. Cliff Dyer
On Fri, 2009-05-08 at 17:19 +0200, Pascal Chambon wrote:
> PS : Am I the only one having most of answers rejected by the
> antispam 
> system of python-list ? That's humiliating :p
> 

I've had several messages not make it through.

:(


--
http://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2009-05-08 Thread Dotan Cohen
> I'm almost 100% sure it won't. The code is machine-generated, thus not easy
> to the human eye, not idiomatic so you don't learn how to write good python
> through it. You learn how to jump through hoops to code the same way in
> python that you do in PHP.
>

I meant for single functions, not for translating entire apps.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
--
http://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2009-05-08 Thread Diez B. Roggisch
Dotan Cohen wrote:

>> I'm not a big fan of PHP but I don't understand the desireability of
>> such a tool.  If you have a good PHP app just run it.  The point of
>> Python in my mind is that it is a cleaner syntax and promotes better
>> code.  Anything that converts PHP to Python is going to leave you with
>> some butt-ugly Python.  It also risks adding new bugs.
>>
>> If you want a Python version of Drupal then perhaps that is the project
>> that you want to start.  Start fresh using the existing project as your
>> requirements specification.  Don't automatically import all their
>> coding choices that may be partially based on the language used.
>>
> 
> It would be a great learning tool. I am pretty decent with PHP but
> just getting started in Python. This might help such users flatten out
> the learning curve.

I'm almost 100% sure it won't. The code is machine-generated, thus not easy
to the human eye, not idiomatic so you don't learn how to write good python
through it. You learn how to jump through hoops to code the same way in
python that you do in PHP.

Diez

--
http://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2009-05-08 Thread D'Arcy J.M. Cain
On Fri, 8 May 2009 19:33:10 +0300
Dotan Cohen  wrote:
> It would be a great learning tool. I am pretty decent with PHP but
> just getting started in Python. This might help such users flatten out
> the learning curve.

If there were such a tool available I would sugegst it come with huge
warnings suggesting that the resulting code not be used for learning
purposes.  You would still be much better off with the tutorials.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
--
http://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2009-05-08 Thread Dotan Cohen
> I'm not a big fan of PHP but I don't understand the desireability of
> such a tool.  If you have a good PHP app just run it.  The point of
> Python in my mind is that it is a cleaner syntax and promotes better
> code.  Anything that converts PHP to Python is going to leave you with
> some butt-ugly Python.  It also risks adding new bugs.
>
> If you want a Python version of Drupal then perhaps that is the project
> that you want to start.  Start fresh using the existing project as your
> requirements specification.  Don't automatically import all their
> coding choices that may be partially based on the language used.
>

It would be a great learning tool. I am pretty decent with PHP but
just getting started in Python. This might help such users flatten out
the learning curve.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
--
http://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2009-05-08 Thread Pascal Chambon


D'Arcy J.M. Cain a écrit :

On Fri, 08 May 2009 17:19:13 +0200
Pascal Chambon  wrote:
  
That's funny, I was precisely thinking about a php to python converter, 
some weeks ago.
Such a tool, allowing for example to convert some CMS like Drupal to 
python, would be a killer app, when we consider the amount of php code 
available.



I'm not a big fan of PHP but I don't understand the desireability of
such a tool.  If you have a good PHP app just run it.  The point of
Python in my mind is that it is a cleaner syntax and promotes better
code.  Anything that converts PHP to Python is going to leave you with
some butt-ugly Python.  It also risks adding new bugs.

If you want a Python version of Drupal then perhaps that is the project
that you want to start.  Start fresh using the existing project as your
requirements specification.  Don't automatically import all their
coding choices that may be partially based on the language used.

  
I agree that, in any way, the code resulting from this translation would 
be anything but pythonic :p


The point would rather be to consider code translated from php, ruby, 
perl or anything as extension modules, which have to be wrapped with 
pythonic interfaces (much like c/c++ libraries actually), or which are 
supposed to be deeply refactored.
It's always a pity when libraries available in a language have to be 
reproduced in another - even though building the translation tools would 
maybe ask for too much effort.


Concerning applications, like Drupal, it'd be different of course - I 
have no precise plan on how Drupal could be translated and then made 
"maintainable" in python, but for sure Python lacks a similar CMS, 
easier to approach than Plone and much more feature-full than others 
(Slemetonz, Pylucid...). And I don't feel quite ready for implementing 
such a thing myself ^^


Maybe the translation approach isn't the right one ; surely the best 
would be an interoperability at a lower level, like we have in Jpype, 
the DLR of .Net, Parrot, ironclad etc... but even with those projects, 
we're far from a fluent interoperability between languages, which would 
allow you to pick the best modules in the languages that fit the most 
for each of your tasks, on the platform you want  (I guess that's just a 
geeky dream).


Regards,
pascal


--
http://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2009-05-08 Thread Pascal Chambon

D'Arcy J.M. Cain a écrit :

On Fri, 08 May 2009 17:19:13 +0200
Pascal Chambon  wrote:
  
That's funny, I was precisely thinking about a php to python converter, 
some weeks ago.
Such a tool, allowing for example to convert some CMS like Drupal to 
python, would be a killer app, when we consider the amount of php code 
available.



I'm not a big fan of PHP but I don't understand the desireability of
such a tool.  If you have a good PHP app just run it.  The point of
Python in my mind is that it is a cleaner syntax and promotes better
code.  Anything that converts PHP to Python is going to leave you with
some butt-ugly Python.  It also risks adding new bugs.

If you want a Python version of Drupal then perhaps that is the project
that you want to start.  Start fresh using the existing project as your
requirements specification.  Don't automatically import all their
coding choices that may be partially based on the language used.

  
I agree that, in any way, the code resulting from this translation would 
be anything but pythonic :p


The point would rather be to consider code translated from php, ruby, 
perl or anything as extension modules, which have to be wrapped with 
pythonic interfaces (much like c/c++ libraries actually), or which are 
supposed to be deeply refactored.
It's always a pity when libraries available in a language have to be 
reproduced in another - even though building the translation tools would 
maybe ask for too much effort.


Concerning applications, like Drupal, it'd be different of course - I 
have no precise plan on how Drupal could be translated and then made 
"maintainable" in python, but for sure Python lacks a similar CMS, 
easier to approach than Plone and much more feature-full than others 
(Slemetonz, Pylucid...). And I don't feel quite ready for implementing 
such a thing myself ^^


Maybe the translation approach isn't the right one ; surely the best 
would be an interoperability at a lower level, like we have in Jpype, 
the DLR of .Net, Parrot, ironclad etc... but even with those projects, 
we're far from a fluent interoperability between languages, which would 
allow you to pick the best modules in the languages that fit the most 
for each of your tasks, on the platform you want  (I guess that's just a 
geeky dream).


Regards,
pascal


--
http://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2009-05-08 Thread D'Arcy J.M. Cain
On Fri, 08 May 2009 17:19:13 +0200
Pascal Chambon  wrote:
> That's funny, I was precisely thinking about a php to python converter, 
> some weeks ago.
> Such a tool, allowing for example to convert some CMS like Drupal to 
> python, would be a killer app, when we consider the amount of php code 
> available.

I'm not a big fan of PHP but I don't understand the desireability of
such a tool.  If you have a good PHP app just run it.  The point of
Python in my mind is that it is a cleaner syntax and promotes better
code.  Anything that converts PHP to Python is going to leave you with
some butt-ugly Python.  It also risks adding new bugs.

If you want a Python version of Drupal then perhaps that is the project
that you want to start.  Start fresh using the existing project as your
requirements specification.  Don't automatically import all their
coding choices that may be partially based on the language used.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
--
http://mail.python.org/mailman/listinfo/python-list


Re: php to python code converter

2009-05-08 Thread Pascal Chambon

Hello

That's funny, I was precisely thinking about a php to python converter, 
some weeks ago.
Such a tool, allowing for example to convert some CMS like Drupal to 
python, would be a killer app, when we consider the amount of php code 
available.


But of course, there are lots of issues that'd have to be fixed :
- translating the php syntax to python syntax
- forcing scope limitations where php doesn't have any
- handling differences in semantics (for example, the booleanness of "0" 
or)

- handling the automatic variable creation and coertion that php features
- handling the php types like arrays (which are neither python lists nor 
python dicts)
- providing a whole mirror of the php stdlib (string and file functions, 
access to environment vars...)


Some things, like PECL modules, would imo be almost impossible to handle 
(there are already so much trouble to make Cpython extensions available 
to other python implementations...), but I guess that 95% of existing 
php websites could be wholly translated "just" with a language 
translator and an incomplete stddlib replacement.


That's hell a lot of work anyway, so it'd be worth weighing it ^^

Actually, your module "phppython" might already be rather useful, 
because I've crossed here and there people desperately asking for help 
when translating some php function of their own to python.


But if the project were to become bigger, I guess some choices would 
have to be rechecked. For example it seems you parse the php code your 
own way, instead of using existing php parsers ; I think the most 
flexible way would be walking some kind of php abstract syntax tree, and 
translating it to python AST on the way. Also, writting the comments in 
english woudl be mandatory :p


I'd like to have the opinion of people around : do you think that 
complete language translators like php<->python or ruby<->python are 
possible ? Impossible ? Not worth the effort ? Or must be reached by 
another way (eg. Parrot and stuffs) ?


Regards,
Pascal

PS : Am I the only one having most of answers rejected by the antispam 
system of python-list ? That's humiliating :p


bvidinli a écrit :

if anybody needs:
http://code.google.com/p/phppython/
--
http://mail.python.org/mailman/listinfo/python-list


  


--
http://mail.python.org/mailman/listinfo/python-list


php to python code converter

2009-05-08 Thread bvidinli
if anybody needs:
http://code.google.com/p/phppython/
--
http://mail.python.org/mailman/listinfo/python-list