Ask HN: How will it impact my webapp if it is written in Python instead of PHP.
Folks, I have seen too many HN posts on the fact that PHP is not a good language to develop a robust web application, despite of the fact few of the biggest web sites are running on PHP. We(my team and me) started debating on the issue of choice of the technology for the next project. I am still in some ways not convinced that python may be a better approach.
PHP and Python
* Both have good framework web.py | codeigniter
* Both have good helpful community and support
* Both large set of plugins
How will it impact my webapp if it is written in Python and not PHP
88 comments
[ 3.2 ms ] story [ 170 ms ] threadIt's possible to write good code with PHP, but a great deal of the example code you'll find online is not good. On top of that, the language itself tends to encourage bad design (see "broken window theory").
Python has a strong culture of having one obvious and good way to do things. In some situations, that can feel restrictive, but it tends to make dealing with code other people wrote easier.
Most of the complaints I can think of about PHP that are objectively demonstrable are outdated. The language now has namespaces, closures and the like. Most of the complaints I have left have to do with the feel of the language, and some remaining cultural elements; it feels like a ghetto, even though it seems to have modern infrastructure now.
This is, I think, where people new to Python stumble up. If they were Dutch, the obvious way would be easier to spot.
I say this as someone who is working on a Pylons site. You can do anything with Pylons that is possible with Python, you just have to figure it out yourself or twist someone else's library to make it work. Sometimes you don't need that much freedom and the guided approach will do 90% of what you need. Do a bit of research and see which approach best suits your needs.
As you say, however, Django is a good place to start for a beginner - it has a larger community and ecosystem of apps for doing just about anything web-related (although the apps are of variable quality). It's also quite mature (5 years now) and has more job opportunities.
applications, not plugins
Work through a Python tutorial (I suggest "Dive Into Python") first and then set up Django and work through the Django tutorial. Build a small app of your own with Django.
If you are a decent programmer all the above should take you a weekend at most.
And then you'll have some first hand experience about difficulty of transition etc.
Fwiw, I prefer Django to PHP. But then I am biased so use appropriate amounts of salt. I'd kill myself if I had to work for very long in PHP.
I'm biased towards Python.
Perhaps more importantly, many skilled developers favor Python and will avoid PHP. When you seek to grow your team, you will likely draw from a better talent pool if your application is written in Python.
"PHP is just like every other language: it allows you to write horrible, insecure, stupid code. It also allows you to write clean code."
Really, the language doesn't matter. Find people who write good code and give them the tools and atmosphere to do so, and your code will be good. Both are mature languages with plenty of time put into plugins, security, and documentation. Both can obviously scale well, and both have the same set of capabilities barring some specific edge cases.
[1] - http://www.quora.com/What-are-PHP-s-main-flaws-(and-good-par...
I disagree.
Python, by design, makes it hard to write bad code. PHP, by design, encourages bad code.
Every language/IDE combination encourages a 'default' coding approach, I agree that the PHP 'default' coding approach tends to be to create a hopeless muddle of assorted, random crap. OTOH, which would you rather have...a coder who is currently being 'forced' to write marginally better code in Python than he would in PHP because of the language constructs, or a coder who understands good code design and knows how to apply it?
A good coder will be a good coder in any language, the fact that a crappy coder can be made to look marginally better if they are forced to use Python just doesn't feel like much of a win to me.
That's an esoteric question.
A good coder wouldn't choose PHP in first place, unless there are pressing reasons (i.e. a legacy code-base).
Consequently you can speed up your hiring process simply by weeding out candidates who propose to use PHP.
'No true scotsman...'
FWIW my hiring process rarely includes a request that candidates propose the language that they will perform their work in.
(oh, and its not an esoteric question. It is a deeply practical one. I desperately want to hire good, pragmatic coders, not people who are only capable of writing good code if they are in an environment that makes it easy)
Moreover it's highly unlikely that a good coder would apply for a PHP job in first place.
I agree with the second part, but I think the first part is wrong.
I think he wants coders to create and maintain software that the company will use on a daily basis, in which case, PHP is perfect for that.
that would make it IMPOSSIBLE. muah ha ha.
(In fact the latest version of PHP (5.3) can, but for years PHP has been lacking this, so the point stands.)
No amount of "good code design" can work around core features that are missing from a language.
The argument that all languages are more or less equal is as nonsensical as saying all cars are more or less equal, or all guns are more or less equal -- it ignores the tremendous advantage that using good tools can provide.
well, as you've pointed out yourself, yes it can.
"for years PHP has been lacking this, so the point stands."
Im sorry? I must be missing the point. How does the presence (or absence) of a particular language feature prove or disprove the point that bkrausz made originally?
"..<snip>...it ignores the tremendous advantage that using good tools can provide."
not really. well, kind of.
so the thing is that if I take the things that (in my experience) work to make a project successful, and I squash them all up into a big ball, and then I take that ball and I split it up into two heaps....one heap consisting of the things that the developers brought to the project and one heap consisting of things that the language brought to the project...and I look closely at the relative sizes of those two heaps....then almost always the heap of things that the developers brings is a lot larger; so much larger in fact that in general the effect of the programming language can be ignored.
That is a pretty general statement, and there are clear cases where it is simply not true, but in general it is true, and I would particularly claim that in the case of a web application and choosing between PHP or Python, it absolutely is true. In the hands of good developers either will solve the problem well, both will provide a good, readable and maintainable code base. In the hands of an idiot, neither will be any good.
Yes, you are missing the point. I refer to closures, the feature at the core of functional programming, not just any "particular language feature". Functional programming is an extremely powerful tool to wield, and has been absent from PHP since its inception until very recently.
A great developer with a functional programming tool in hand is able to well outperform a great developer who must work around its absence.
Here's a paper that surfaced to the front page of HN recently on the importance of functional programming: http://news.ycombinator.com/item?id=1482797.
This is just one example, but a very potent one, of why language selection matters.
we really do appear to be having two different discussions, Im neither claiming that PHP is 'better' than Python nor am I arguing against functional programming.
I am simply arguing that the most important thing in a project is the quality of the developers, not the language they chose; and that given a good developer and a choice between PHP and Python I would almost certainly find the relative language features so entirely unimportant that I would choose the language based on stupid things like what language the existing codebase is in, what language the developer preferred and had most experience in and how recently I had been frustrated by the languages in question.
OTOH, I am always willing to debate the relative importance of language features, so by all means lets go there.....
Closures in particular are a very powerful tool in async/multi-threaded environments, but in the stateless/sync environment of a web application environment, they collapse down to syntactical sugar, and solve nothing that cannot be solved in other ways.
The software industry has, by and large, been working around the absence of closures for years....I certainly wont argue that it is better because of it, but to claim that PHP has been seriously crippled by the absence of closures over the years is to entirely overlook and understate the multitude of other problems its users have had to overcome.
I agree with the first part, but I think the language choice is integral to just how good those good developers can be.
I don't believe for a minute that a great developer can develop in PHP without being seriously crippled by it.
Functional programming has a tremendous amount of value outside of async/multi-threaded environments that cannot simply be replaced by other means. There are real limits to the amount of modularity one can achieve without functional programming, and modularity is key to great programming. I'd point you again to this paper: http://news.ycombinator.com/item?id=1482797
The state and history of the software industry at large only demonstrates that the majority of software developers in key technical positions within the industry are and have been less than great.
But if your argument is that PHP is "good enough" given a bunch of average developers... well then, yes, probably. Certainly plenty of good software has been written in PHP. I'd just argue that with the right developers it's far less than optimal, and that the choice of language could easily be the difference between the success and failure of a complex project.
Functional programming, or closures? I said: "Closures in particular are a very powerful tool in async/multi-threaded environments, but in the stateless/sync environment of a web application environment, they collapse down to syntactical sugar, and solve nothing that cannot be solved in other ways."
I made absolutely no statement regarding functional programming in general, and the label 'functional programming' applies to a much broader set of topics than just closures, so I am entirely at a loss as to why you think it makes sense to 'rebut' my statement about closures with something about functional programming?
"There are real limits to the amount of modularity one can achieve without functional programming, and modularity is key to great programming."
I entirely agree, modularity is good.
"The state and history of the software industry at large only demonstrates that the majority of software developers in key technical positions within the industry are and have been less than great."
indeed.
"But if your argument is that PHP is "good enough" given a bunch of average developers..."
LOL.
It really wasn't.
Im glad you like functional languages and closures, you really should check out Scheme - its even MORE functional than Python.
Closures allow for abstractions that are impossible to achieve without them. Yes, you can always get the same functionality, but you will be forced to deal with a weaker abstraction.
PHP has closures however.
Every feature in every language is syntactic sugar for ASM instructions and solves nothing that cannot be solved with raw machine code. It's precisely the expressiveness of the higher-level features that gives them their power.
Actually, it's been able to do that for a LONG time. Pretty sure (99.9% sure here) you could do that in PHP 4, and probably in PHP 3 as well (but really, it's been so long, forgive me for not remembering). Different syntax, of course, but yeah, you could do that.
PHP 5.3 essentially just made it more explicit.
Edit: When I say different syntax, I mean slightly different syntax, obvious, because it's Python being reference. The end result, however, is the same.
And, if I may be so bold, the PHP way prior to PHP 5.3 (though still supported), encouraged a cleaner implementation then the 'Cook' example demonstrated in the link above.
A quick Google search shows that PHP 5.2 and earlier seem to support something like the anonymous functions required in the example I linked to above -- via the create_function method. But using it in practice appears to be full of ifs, buts and complexities: http://nz.php.net/manual/en/function.create-function.php#706...
But maybe one could get it work if used with care.
If I were ever chained to a desk and forced to work with a PHP framework like Drupal that does not yet support v5.3, I'd look in to this.
Otherwise I'd choose a language that cares more for concepts like readable code and deep modularity.
Invoking an object callback in PHP:
Invoking an object callback in Python: Although PHP is slowly adding useful modern language features (lambdas, closures), some of the syntax really is terrible. I honestly can't imagine anyone preferring the former to the latter, at least in this example.It's probably more important to just getting something done in the first place. You can probably rewrite when you get some revenue.
Neither failed, because they were smart enough to know when to ditch. God knows how many startups failed because they didn't know that.
(If you want an invite to Fosdev for trying out GAE quickly, let me know.)
State of web programming in python:
The frameworks:
Django: More powerful? No. Faster, more seductive. In the long run you'll outgrow it, if you are any good. It gets you from zero to twenty five percent almost instantly, then gets in your way. The ORM is a terrible mess. The template language is easily the worst (slowest by 10x, slow enough that common templates take 300ms to render, insanely unusable 500 line tracebacks), of any of the common python templating languages. Once you swap out the ORM and the templates, you suddenly realize what is left is also a piece of crap. Django middleware are horrid. I remember trying to write a database session middleware and an error-reporting middleware in django, only to determine it is literally impossible (there are edge cases where any middleware can be skipped and never see the request). When having to deal with it, I use it's oddball WSGI adapter and park WSGI middleware in front if it. I can not say enough bad things about django, it is rotten through and through compared to the alternatives. The admin interface is neat, but is basically a toy once you run into real complexity or data volume. I might use django if I were making a content based application on contract, since the admin interface would be a huge piece of free functionality, or a very simple web app, like a hotel website or something.
Pylons: WSGI based, thank the lord. This means you can write real, flexible, efficient, predictable middleware. I was a huge Pylons fan from around the beginning of 07 until I discovered Werkzeug near the end of 08. I still lurk in #pylons quite a bit, and it was at my urging that the Banquet library (a common interface to all template systems) was discarded (although it may have been on it's way out anyway). Pylons uses great libraries under the hood (webob, beaker, etc), and I would recommend it without hesitation. The __call__ method of the BaseController class used to be a complete mess, I would guess that it still is. Luckily you only run afoul of it very occasionally. the __before__ and __after__ methods are handy. When I stopped using it they were still recommending AuthKit officially, but the mood of #pylons seemed to be (and I agree) that AuthKit is a horrifying abortion that should never be used. The canonical stack with Pylons is Pylons-SQLAlchemy-Mako. I would swap Mako with Jinja2, although who use Mako tend to be loyal to it, and there aren't too many huge warts (the way it does template inheritance makes my head hurt though). TLDR-Pylons good.
Werkzeug/Flask: My personal favorite. You are building a web application, you should have all the moving parts where you can adjust them as necessary without bolting on bizarre hacks, and Werkzeug lets you do that. It may be a bit of a jump for a beginner. Flask is an attempt to make a 'framework' out of Werkzeug, and it seems to be getting some momentum. If you know what you are doing, I believe Werkzeug is the best thing out there for Python web programming.
Tornado/Twisted: Either is great. Due to the pain of dealing with them (you need special event driven db adapters, etc) I would only use them for long-polling applications or the long polling portions of a general application.
Also rans: Turbogears: crap, web.py: crap. Also also rans: Zope (if you don't know what it is already, you probably don't want it).
How to deploy:
mod_wsgi for Apache is the one true way to deploy python web applications. Anything else (fastcgi, reverse proxy, etc etc) is a hard to maintain, unreliable, mess. I would put mod_wsgi on each webserver, and have a machine running nginx or varnish or pound as a load balancer. Varnish is the best if you want to do sophisticated caching or edge side includes, nginx is easy and ...
My default stack is Werkzeug+SQLAlchemy+Jinja2. Deployed on Apache/mod_wsgi. If a customer wants Windows/IIS, I deploy using isapi-wsgi.
Buffet.
Django is incredibly easy to get going, and you can rewrite bits of it as you need to. It's reasonably easy to switch out the templating language if you need to, and I haven't had any problems like you describe with the ORM or admin app. For prototyping apps I wouldn't use anything else. I'm currently running with nginx/FastCGI and haven't seen any problems.
Pylons and SQLAlchemy, on the other hand, I found hideous - lots and lots of boilerplate, particularly when setting up models, weird tracebacks that had no relation to the original problem, poorly integrated bits - I basically couldn't populate databases from a unit test, then run a controller, then check the results, since SQLAlchemy would lose the connection after the controller.
What you say makes no sense. SQLAlchemy just uses the usual adapter for whatever database you are using. What does "loses the connection" mean to you? SQLAlchemy, by default, uses a pool of connections. I suspect you tried it for an hour and gave up without really understanding what you were doing.
This however does work in Django - presumably by somehow passing the same DB connection to the test server.
Maybe there's a way to do it properly within SQLAlchemy, but if so it's completely non-obvious from a few days of searching the web, Pylons documentation, Pylons book, mailing list, etc.. I wasn't trying to do anything fancy, just set up a very basic unit test.
Here's one of my old comments with some more detail: http://news.ycombinator.com/item?id=1176948 "Instance <Foo at 0x103779f90> is not bound to a Session" was the error that I was getting.
The following is more of a screed than a personal response to your post, so please don't take it personally.
This is something I run into quite a bit more than you might expect. Partly it is because I used to spend a lot of time in #sqlalchemy, #pylons, #pocoo, #python, and #postgresql on freenode (I'm 'ltbarcly' on freenode, feel free to msg me HNers!). For some reason it is common to believe that you can sit down and write applications that use an ORM and relational database without knowing both the ORM and relational databases.
If you are going to use relational databases, you should be prepared to become an expert in SQL, Database drivers, unicode (and why utf-8 or any other encoding isn't the same as unicode, in the same way that jpg or gif isn't the same as image data), indexing, data types, normalization tradeoffs, transaction isolation levels, locking semantics, ACID tradeoffs, how to read and understand query planner output, and much more. This is a lot to know, but if it were a college class it would be less than a semester long.
If you are going to use an ORM you have to know everything you would need when you use a relational database, and in addition how and when the ORM performs queries, how it maps to the database, what queries it will produce and when for any given action or attribute access, how db transactions map into the orm operations, how to perform common SQL operations via the orm (rather than loading more data than you need and filtering or joining via the application).
- plugin ecosystem. Not necessarily at the beginning, but tha architecture should make it easy enough to add plugins (or apps, or extensions or whatever they are called by the framework) that developers feel encouraged to do so.
- high profile sites or projects, or at least a high volume of sites, so developers can answer manager's question, "Well, who uses it ?". Again, no framework will have this at the beginning but it will need this to get big (bit of a chicken and egg situation).
- good documentation, preferably but not exclusively online. Good == well written, up to date, well organized and consistent.
- good marketing: maintainers who can blow their own trumpet in the blogosphere, conferences, books, Twitter etc etc.
Now the code may be crap, and it may not have this feature or that feature, or it may or may not be easy to extend or customize. But the above points are required if it is to stand a chance.
Django, despite the flaws you mention (and I agree with some of them, and could add a few of my own) meets these criteria. It has the sites, the documentation, a healthy ecosystem of apps (though of varying quality), and is marketed by people who work, or used to work, in the newspaper business.
Flask, as an up-and-coming framework, is just a couple months old, so obviously doesn't have the ecosystem or the high profile/high volume yet. But it is well-positioned to take off : the documentation is excellent, and it has a good plugin architecture, with about a dozen or so "official" extensions already. Whether or not it does take off depends on many other factors, but I'd say it's future looks quite promising. It may need some aggressive marketing, or at least one or two high profile sites.
Pylons, OTOH, doesn't look so healthy. Documentation, last I looked, was out of date, poorly organized, and contradictory (AuthKit is recommended in the docs, newbies use AuthKit, get confused by its crapiness, go on IRC, and get told "don't use Authkit" - why is it still in the docs at all ?).
It's not so easy to add plugins, except at the WSGI level, which is often the wrong level of abstraction, plus there is the confusion of "entry points" and how to make it all work with Paster. As a result (and also because of the pisspoor docs) despite being around almost as long as Django, Pylons doesn't have a good plugin ecosystem. It has one high profile site - Reddit - but otherwise for the time it's been around I can't think of many others.
What matters is having great coders, great ideas for your app and executing them effectively and efficiently which is possible with both PHP and Python.
You can write horrible code with both languages, it might be horrible in a different way but it'd still be horrible. :D
That said, if you're the only one having doubts about Python but the rest of your team wants to write the app in Python and they do have experience working in Python - why don't you trust your team's judgement?
As it doesn't matter, it would be the sensible decision to pick the language your team would like to code in, imho. :)
Python for maintainable code.
Python for better libraries.
Python for Google App Engine and .NET
Python because of a cleaner grammar and better syntax.
Python for you.
The best thing you can do is promote the guy who's clamoring the loudest to steer clear of PHP to technical lead, and defer all future technical decisions to him.
The language is just a tool. Consider car racing. If you have a poor driver in the fastest car, it won't make a difference. No matter how fast the car is that he's driving, he's going to lose. And if you have a great driver in a slow car, no matter how good he is, he's going to be limited by the speed of his car.
If you have a poor technical lead, it won't matter what language you choose. You can give him a great language, but he will not understand and take advantage of its best features. If you have a good technical lead, but you choose a bad language, the quality and pace of his development will be forever limited by the language.
(And in the context of a team, the abilities of the team to make good technical decisions are limited by the technical direction your technical lead sets -- which is why you need the most talented guy in the position of technical lead.)
The guy on your team who is the most against using PHP is likely the one who best understands the ways in which PHP will limit your team. You do not have the deep technical understanding to make these judgments, and for that reason (without taking months of hard work to gain such understanding) you should defer to him.
Yes, some of the largest websites are written in PHP. But you do not have the same level of resources to throw at the problem that they have.
You're also starting your development at least 5 years later than any of the largest websites that you refer too. Frameworks/plugins/communities evolve quickly. There were more reasons 5-10 years ago to choose PHP then there are today. Companies that have already written millions of lines of code in PHP will find it very hard to switch to another language -- but you do not have to deal with the weight of such legacy issues.
As a small team, you need to look for every advantage you can get. Choosing a programming language that makes your developers more productive is an important part of that.
If you care about framework, community and plugins, Ruby is also a better language than PHP, and Rails provides these three things in spades. Assuming you don't have a good system administrator on your team, companies like Engine Yard and Heroku provide scalable managed Ruby on Rails hosting -- so you can outsource combating issues like down-time and data loss.
sorry, what? the guy on his team who is most against using PHP could equally well be an idiot who is simply repeating stuff he has heard on the web by rote, using regurgitated puff to hide his complete lack of understanding of both the issues and the languages themselves.
Your willingness to entirely overlook that possibility and to make the kind of sweeping statements you have made in your post in the absence of any data causes me to doubt that you have the kind of experience and technical expertise that is required to make that kind of statement.
I don't envy the position of any non-technical person that has to make key technical decisions on a technical project.
Ultimately it takes a good developer to spot a good developer, so a non-technical person seeking to build a "robust web application" starts at a huge disadvantage.
Without understanding the pros and cons of each language choice, all he can do is gamble on finding a smarter person than himself that he can trust. I'm advocating he choose the anti-PHP guy, slightly tongue-in-cheek, because given the limited amount of information presented, that choice gives him the best odds.
Being in the position of having to make such a bet is less than desirable, but given his lack of technical knowledge, what else would you have him do?
He asked: "How will it impact my webapp if it is written in Python and not PHP"
That is a fantastic question, and it deserves better responses than the 'language x sucks' ones it is mostly getting.
The simple fact that he asked the correct question gives me a great deal of faith that he is in fact technically inclined, technically able and has some development experience. The way in which it was phrased makes me believe that english is not his habitually spoken language.
He clearly does lack experience in using Python, and is (quite reasonably) hesitant about plunging into a different language without attempting to find out more about it.
"I'm advocating he choose the anti-PHP guy, slightly tongue-in-cheek, because given the limited amount of information presented, that choice gives him the best odds."
it really doesn't. some quite ridiculously stupid people are anti-PHP.
Given the information available, I would advocate that he use the language that the majority of people on his team are most familiar with. Nothing like having a team learn an entirely new language and associated design skills to bog down a project.
I'm sure he has development experience. But too limited an amount.
It is a valid question, but I don't think any response provided here can properly demonstrate to him the value of a language like Python over a language like PHP. No more than someone could teach him to fly a plane in the span of a post like this. It's not a simple subject, by any means.
The best anyone can do is point him to resources that he could study and learn over a period of time -- or advise him to listen to someone talented that he trusts.
I'd be very careful listening to anyone advocating PHP for a project starting from a blank slate. Yes, there are talent developers that prefer PHP. And there are many more poor developers that prefer PHP as is the most popular default choice for those that lack experience, are not comfortable with their own technical judgement, or believe that all languages are more or less equal.
Many on HN would argue that a top-tier developer would not choose PHP, period. But you may not be able to get hold of a top-tier developer -- and in that case a team of solid PHP developers may be the best available choice, if not the best possible choice, particularly if you've worked with them before, and the project is technically simple and limited in scope.
Oh, I entirely agree. The practical differences between them in a web application just aren't that important.
Django - Until 1.2 Django was a total headache but with 1.2 it really is a great tool to develop web applications. No reason not to use it unless you feel something's missing. Django has an amazing community with very helpful people.
web2py - web2py lets you create apps very fast, it doesn't push you hard and you can build something in a very short time. However when things get complicated, you will want to quit web2py. I don't like its form helpers, I don't like its validation as the validation is unfortunately not per object but the input data and url routing is headache with web2py. Web2py also has a great community. All your questions will be answered in a short time.
turbogears - turbogears is a subset of pylons with sqlalchemy as orm and genshi as templating system. i don't like the @expose decorator. it's just not for me. provides many other tools by the way. TurboGears has a small but helpful community. SourceForge is using TurboGears.
werkzeug - now this is the framework of my choice. the endless freedom. it is only a skeleton which lets you dress your application onto it very easily. you can choose anything as your orm and templating system. provides a strong url routing mechanism. supports sessions, secure cookies and any other thing you may need. however i am not using werkzeug anymore as i don't like the way people act in #pocoo on freenode. this is the only reason i am not using werkzeug. they are ignorant and i don't like it.
Pylons - My favourite Python framework of all times. Flexible as much as it can be. Provides you the freedom you need for anything. I strongly recommend using Pylons. I am currently using Pylons and I'm very happy with it. Pylons is also used at some very popular web sites such as bittorrent.com, reddit.com, etc. It has a helpful community whenever you need.
Frameworks aside, how will using Python will help you? * Very clean and beautiful code. * Easy updating and maintaining the code. * Easiness and laziness. * Great set of libraries. * Python for your mental health.
And I'd like to thank justin_vanw for the great sum. :)
Care to explain? I dont lurk in #pocoo but I am confused as to why you are putting an entire room on blast.
And Werkzeug, I cannot recommend more highly.
If anything you seem a bit ignorant for rejecting a framework you otherwise seem to like because of an IRC channel.
If you are going to call a whole lot of people - some of whom are among the best coders in the Python community -ignorant, I'd suggest coming up with some examples.
Would be nice to know if this is a general thing or if we did something in particular wrong. Because if that is what you remember of this channel we should really improve our behaviour then. So it would be nice if you could elaborate on that.
and let me note that werkzeug is a framework that i'd like to see at the top and people know its value.
One thing I've really liked about PHP is that (using Apache) if the webserver is up, PHP is up. When I developed most of the applications in Python, it seemed as though I was constantly worrying about the application process failing, even though this happened very rarely.
PHP really is an ugly language, but you eventually get used to it. :(
There are enough implementations of both languages in the real world (YouTube - Python, Yahoo/Facebook - PHP)
If you move to something like Tornado (python), Twisted (python) or node.js (javascript) then you might be able to get more performance out of your app, but really only if think moving to that level of complexity is necessary for you app.
In general, it's best to go with what you know. Yahoo! uses a lot of PHP as does Facebook. Since you mentioned CodeIgniter specifically, you're already well down the path of using a framework that allows you to write modular and reusable code with PHP.
If you use php, check out symfony. Codeignighter is crap once you get to know you way around symfony. Php is something I feel comfortable using and know my way around. I use it for all my web sites.
The reason I am learning python is to use the app engine. It looks like a cleaner language then php and seems to be slightly more powerful.
I think it would come down to 1) does your developer know php, python, or both? Let him develop in whatever language they choose. 2) where are you gonna do with it? I think there's a time and place to use php and to use python.
A month ago I started dabbling in Pylons. It's the best framework I've ever used. The Pylons Book is great, if a bit outdated. The official docs are nice (they seem nice to me; I've been burned by Apple's shitty documentation). The entire framework basically consists of glue code to tie together best-of-breed Python libraries: Mako, SQLAlchemy, Beaker, WebOb, PythonPaste, FormEncode, HTMLFill, Routes. Oh, and it's all WSGI. WSGI is the best thing to ever happen to Python web development. You should at least skim the WSGI PEP (PEP 333) if you're serious about Python web development.
Next, I'm planning to check out Werkzeug. It's an even tinier set of libraries that allow you to, in effect, build your own framework. If you're building a simple REST-based service, Werkzeug is what you need.
I also know some people who swear by Web2Py. I haven't tried it myself, but I hear it's great for quick and dirty webapps.
PHP has a lower skilled mean programmer who does it. This is not necessarily a bad thing if cheaper programmer is better than better programmer for your company.
PHP is easier to get going, python has more compelling libraries once you do. Python libraries are often better maintained than their PHP brethren, and the debugging stack for python is much more compelling.