From: Bruno Desthuilliers on
r0g a �crit :
> Bruno Desthuilliers wrote:
>> Sancar Saran a �crit :
>> (snip)
>>> My problem is with PHP syntax and performance. I'm just trying to
>>> replicate my recepies in python...
>> Python is not PHP, and trying to write PHP in Python won't buy you much
>> except pain and frustration.
>
>
> I think people are being a little harsh here. Replicating exactly what
> PHP code does on a micro level i.e. line by line is probably a bad idea
> but for all we know a lot of the macro level stuff might be fine, or
> mostly fine i.e. structures, algorithms, classes and functions etc.

I was talking about trying to replicate PHP's execution model and idioms
in Python - the "framework" part -, not about application specific
algos, data structures etc.

From: AppRe Godeck on
On Mon, 14 Dec 2009 12:25:16 +0100, Bruno Desthuilliers wrote:

> r0g a écrit :
>> Bruno Desthuilliers wrote:
>>> Sancar Saran a écrit :
>>> (snip)
>>>> My problem is with PHP syntax and performance. I'm just trying to
>>>> replicate my recepies in python...
>>> Python is not PHP, and trying to write PHP in Python won't buy you
>>> much except pain and frustration.
>>
>>
>> I think people are being a little harsh here. Replicating exactly what
>> PHP code does on a micro level i.e. line by line is probably a bad idea
>> but for all we know a lot of the macro level stuff might be fine, or
>> mostly fine i.e. structures, algorithms, classes and functions etc.
>
> I was talking about trying to replicate PHP's execution model and idioms
> in Python - the "framework" part -, not about application specific
> algos, data structures etc.

Try web2py I think you will surprise yourself with its simplicity and
speed :)
From: mdipierro on
About you point 3). You may want to look into:

http://www.web2py.com/php

It translates a PHP page into a web2py template. It is crude and
primitive and fails in some cases. Moreover a literal translation is
not what you really want since you want to follow a more MVC design.
Moreover it will not always maps PHP functions into valid Python/
web2py ones. Yet it may be a useful as a learning tool. I made it to
convert Drupal templates into web2py layouts.

Massimo


On Dec 11, 4:26 am, Sancar Saran <sancar.sa...(a)evodot.com> wrote:
> Greetings.
>
> I'm 35 yrs old self learner  and who do daily PHP coding for food more than a
> decade.
>
> After ten years of PHP coding I'm getting bored and give try for learning new
> things.
>
> After 3 days of crawling google, diving in python and cursing, now  I can show
> something on my linux/apache/mod_wsgi setup.
>
> And i'm struck on something.
>
> I had CMS design. It works with PHP very well. And I want to transfer my
> design in Python.
>
> My design depends on a Global Array. A huge array which store everything about
> requested Web page for a final rendering.
>
> In PHP accessing globals is easy. You may do direct access or use class
> something like ZEND Registry.
>
> I'm looking for similar facility in python world.
>
> Also I have couple of questions.
>
> 1-) Can I create Global (read/write access anywhere from my code) Multi
> dimensional, associative array (or hash) and store any kind of variable type.
>
> 2-) Is there any error trigger for mod_wsgi. When something go bad I god
> Internal Server error. Looking for error log was't nice. Is there any way to
> shows errors in the web page ?
>
> 3-) Any documents books sites about helping moving from php to python
>
> 4-) In php we had someting like
> ob_start(); // start Output buffering
> require('hede.php'); // include phtml similar to psp. mixed language and html
> (to avoiding string replacement (or marker based) html templates)
> $var = ob_get_clean(); // get rendered output and use anywhere
>
> can find a similar abilities in Python ?
>
> 5-) is there any Python documentation based on examples. When I give up about
> to finding  php's $_REQUEST or $_SERVER equivalents in python some demo code in
> Twisted docs are much helpful than any other words. Me and my kind already
> have  problem with English language. Example code much more helpful than full
> academic description.
>
> Thanks for support and patience for this old noob.
>
> Regards...

From: Bruno Desthuilliers on
AppRe Godeck a écrit :
> On Mon, 14 Dec 2009 12:25:16 +0100, Bruno Desthuilliers wrote:
>
>> r0g a écrit :
>>> Bruno Desthuilliers wrote:
>>>> Sancar Saran a écrit :
>>>> (snip)
>>>>> My problem is with PHP syntax and performance. I'm just trying to
>>>>> replicate my recepies in python...
>>>> Python is not PHP, and trying to write PHP in Python won't buy you
>>>> much except pain and frustration.
>>>
>>> I think people are being a little harsh here. Replicating exactly what
>>> PHP code does on a micro level i.e. line by line is probably a bad idea
>>> but for all we know a lot of the macro level stuff might be fine, or
>>> mostly fine i.e. structures, algorithms, classes and functions etc.
>> I was talking about trying to replicate PHP's execution model and idioms
>> in Python - the "framework" part -, not about application specific
>> algos, data structures etc.
>
> Try web2py I think you will surprise yourself with its simplicity and
> speed :)

I don't like what I've seen from web2py, thanks. Also and FWIW, I don't
see how it relates to the OP ?
From: Aahz on
In article <4b2602a0$0$30660$426a34cc(a)news.free.fr>,
Bruno Desthuilliers <bruno.42.desthuilliers(a)websiteburo.invalid> wrote:
>zeph a �crit :
>>
>> 4) It's better to collect all your eventual output into a string that
>> you print
>
>Yuck ! Definitly one of the worst advises you could give.
>
><OP>
>By all mean, *DONT* do that. Use a templating system instead.
></OP>

Because I know Zeph, I know that you two aren't actually disagreeing. ;-)
Templates are one good way to follow Zeph's advice, but particularly for
small projects they may be overkill.
--
Aahz (aahz(a)pythoncraft.com) <*> http://www.pythoncraft.com/

Weinberg's Second Law: If builders built buildings the way programmers wrote
programs, then the first woodpecker that came along would destroy civilization.