Migrating from PHP to Python...

Richard Jones richard at bizarsoftware.com.au
Sun Sep 2 19:41:41 EDT 2001


On Monday 03 September 2001 09:12, Rick Shin wrote:
> I'm a PHP man looking to migrate to Python for a change of scenery. I've
> skimmed over the specs, but missed a few PHP constructs that I find
> essential.

My first suggestion is that since you come from tha PHP background, you do 
the following, in order:

  1. walk through the Python Tutorial,
        http://www.python.org/doc/current/tut/tut.html
  2. use a web framework to do web programming in - Python's a 
general-purpose programming language, unlike PHP. That means that, unlike 
PHP, it won't have web-centric features "built in". Some web frameworks to 
consider:
       WebWare   - http://webware.sourceforge.net/
       SkunkWeb  - http://skunkweb.sourceforge.net/
       Quixote   - http://www.mems-exchange.org/software/python/quixote/
       Zope      - http://www.zope.org/

     I believe that webware and skunkweb are probably the best bets for 
someone who has done PHP. If you've got an open mind and more time to get 
over the steeper learning curve, Zope is definitely worth the time.


> 1. include()/require()  (is the import function meant for all file
> includes?)

I don't know PHP, but I assume these do the same as Perl's include/require. 
The python equivalent is "import".


> 2. header()  (for redirecting)
> 4. PHPlib's template.inc  (this isn't a construct, but a templating class I
> find indispensable)

PHP, being designed specifically for developing web interfaces, has 
web-centric stuff built in, like header(). Python, being a general-purpose 
language, will require you to do this stuff yourself or use a web framework 
like one of the ones above. There are also templating solutions for python 
out there that don't involve an entire framework. ZPT from Zope is an example.


> 3. variable variables  (or dynamic variables)

Don't know PHP, sorry. The term "variable variables" seems a little odd. 
Guessing, I'd say that python's variables are all variable. The only 
limitation is that some objects are immutable - the contents of a string may 
never be changed, for example. But that's something you'd pick up in the 
tutorial...


> Finally, as someone who develops web apps exclusively, can anyone give me
> any compelling reasons why I should learn Python?

"for a change of scenery"? Personally, I've spent 2 years developing Perl web 
applications and about the same in Python. I'd never again, willingly, 
develop Perl applications of _any_ sort, let alone web stuff. But the 
"market" says that Perl's the bees knees, so what do I know :)


> From what I've read, PHP
> is faster, less resource intensive, and more prevalent (especially with web
> hosts).

So why bother? Really, why are you here at all with this sort of attitude?


    Richard




More information about the Python-list mailing list