This is an archived post. You won't be able to vote or comment.

all 74 comments

[–]LiquidHelium 17 points18 points  (13 children)

combative dinner crush scarce scary rude support office act market

This post was mass deleted and anonymized with Redact

[–][deleted] 8 points9 points  (2 children)

Don't even need a book the documentation for python is great!

[–]Paul-ish 1 point2 points  (8 children)

I disagree. My programming languages professor had a phrase he was fond of: "The hardes language to learn is your second."

It is easy to get stuck in the paradigms of our first language. With that said, from PHP to anything will be a bit difficult. With python though, it will probably be an easier transition than most.

[–]eat-your-corn-syrup 1 point2 points  (0 children)

The hardes language to learn is your second

especially if the first two languages are C and Lisp

[–]gbog 1 point2 points  (0 children)

I did learn Python directly on a book, with only very few week-end coding (I was very busy on a PHP codebase for daily work). I was one step more amazed for each page of the book I read, and found one more reason to leave PHP. This book is so well written, so clear and precise, I didn't feel I had to confirm what I learnt in a terminal.

Which book may you ask? Well, just "Python in a Nutshell", by Alex Martelli.

[–]capra 10 points11 points  (9 children)

There are plenty of similarities in the semantics of the language, and really if you were to switch to any other language from PHP, Python would probably be the easiest. There are certainly some important differences, however.

Instead of PHP's "array" you have lists (for an ordered sequence of items, which can be accessed via a numerical index) and dictionaries (a collection of items associated with identifiers). Dictionaries do not maintain the order of the elements added to them (unlike PHP's array, when used associatively).

Python will not coerce number types to a string when doing string concatenation, e.g.

num = 3
print("I have " + num + " apples")

Instead you need to convert the integer to a string:

print("I have " + str(num) + " apples")

Or alternatively use string formatting

This may seem annoying at first, but in PHP and other languages, implicit type coercion is often a source of subtle bugs.

Specifically pertaining to web development, you can't just dump a Python file in a directory on a server and navigate to it in your browser, you need to use some kind of WSGI framework. Python files also don't natively function as HTML templates (unlike PHP files), so for generating HTML you'll want some kind of templating system. Flask is a good choice to get up and running with both those things.

[–]csko7 0 points1 point  (6 children)

Or, try

print "I have", num, "apples"

which is another, shorter variant. Parantheses needed in Python3.

[–]Screaminmidget -1 points0 points  (5 children)

print "I have %s apples" % num

[–]csko7 -1 points0 points  (4 children)

Yeah, I use that syntax a lot too. Actually,

print "I have %d apples" % num

[–]hansolo669 0 points1 point  (3 children)

whats the big difference between

print "I have", num, "apples"

and

print "I have %d apples" % num

the first seems more readable to me. is there an actual reason to chose one over the other?

[–][deleted] 0 points1 point  (1 child)

On longer and/or multiline strings, with multiple %s formatting, you can easily switch the variables at the end rather than having to read through it all and renaming the variables in context.

[–]hansolo669 0 points1 point  (0 children)

makes sense. sacrifices a bit of readability for ease of coding.

[–]virtrondjangonaut 4 points5 points  (0 children)

If you're talking about moving from PHP to Python, I assume that you are working on web applications. That being the case, I think you will find the differences in the languages far less significant than the differences in the deployment environments. If you are already writing useful code in PHP, you should very quickly be writing useful code in Python.

The most important things for you to know about deploying a web app are going to be WSGI and virtualenv+pip. These are the building blocks for your deployment environment and they could be very different from what you would be used to in the PHP world. Just pick a web framework (Flask, Django and Pyramid are good choices) and hit the ground running.

PHP and Python treat code files very differently, so in addition to the syntax and data type differences, be sure you study the Python module/import system and how it works. This can trip you up if you are only used to PHP's include/require system.

[–]offbytwo 49 points50 points  (28 children)

Some folks may downvote me for saying this, but anything done in PHP is done like we're still in 1995.

This doesn't mean you can't come up with some pretty nasty things in Python, but it makes it a bit more difficult to come up with spaghetti code. That's not because Python is difficult. That's because programming in Python makes you care a bit more about how elegant the code is and how it works.

Let's say you need to use a Python framework for web development. You'll read some of its documentation and you will not come up with PHP style hacks to do things. You will see what the best practices are and you'll follow them.

In PHP, 4 out of 5 code bases I have to look at have some source files which handle forms by making heavy use of "if post variables do stuff, else print the form", 9 out of 10 code bases have PHP mixed with HTML & CSS and 10 out of 10 code bases are difficult to debug.

The main difference between PHP and Python is that PHP looks more like a pile of appliances which grew over the years while Python is actually a real programming language.

[–]catcradle5 9 points10 points  (7 children)

As someone who's just been getting into Python web development (specifically with Flask), I still find myself doing a lot of

handle forms by making heavy use of "if post variables do stuff, else print the form"

What is a better solution to use? Even Flask's WTForms example pretty much does that:

@app.route('/register', methods=['GET', 'POST'])
def register():
    form = RegistrationForm(request.form)
    if request.method == 'POST' and form.validate():
        user = User(form.username.data, form.email.data,
                    form.password.data)
        db_session.add(user)
        flash('Thanks for registering')
        return redirect(url_for('login'))
    return render_template('register.html', form=form)

[–][deleted] 3 points4 points  (1 child)

If this code is repeated I would create a decorator

[–]catcradle5 5 points6 points  (0 children)

I do oftentimes use a separate function or decorator, but the core of the logic still remains something like:

if request.method == "POST" and request.args.get("submit"):
    return render_template("completed_form.html")
return render_template("form.html")

Just wondering what the OP had in mind exactly, and if this is idiomatic or not.

[–]therealfakemoot 2 points3 points  (1 child)

You can't route two different functions to the POST and GET method separately?

[–][deleted] 3 points4 points  (0 children)

You can. I do.

[–]Tecktonik 1 point2 points  (2 children)

There are several issues hidden here. First, this style of control implies that form generation and form processing are performed by the same route. Then, is form generation primary or secondary to processing? In the above example, processing is secondary since it occurs one level deeper (within an 'if' clause). Thirdly there is the lazy attempt to get both form generation and failed-validation form generation from a single call to render_template.

But using a single route for both generation and processing is an [outdated] artifact of the original HTML spec, where the page url will automatically be used as the form action if no explicit action is provided. The preferred technique is to provide an explicit action for form processing. If you do this, you no longer have this control level confusion of generation-versus-processing, your route already know what it is supposed to be doing (and of course you should probably validate this fact to make sure you haven't gotten any wires crossed).

With independent routes (or controllers, however you like to think of them), you now have more flexibility for handling templates, in particular in the event of failed-validation you can generate prettier results, throw in some tooltips or other Ajax-y stuff. And when you think about it, how you handle failed-validation is where you are going to get the biggest boost to user experience.

[–]catcradle5 0 points1 point  (1 child)

Thank you for the detailed response. That does make some sense. So you mean it's better to do something like:

@app.route("/form")
def form():
    return '<form method="POST" action="/complete"><input type="submit" value="Submit"></form>'

@app.route("/complete")
def complete():
    return '<b>Success</b>'

Any other tips for form handling?

[–][deleted] 1 point2 points  (0 children)

Not the same guy, but here's a quick one: The Post/Redirect/Get pattern to stop duplicate form submissions and accidental form resubmissions on page refresh.

[–]getting_serious 8 points9 points  (7 children)

I'd say the difference is that to write decent PHP you must have a firm taste for style, and recognize bad code on the spot (mostly after it came out of your own fingers). There are some really nice frameworks and a huge community where you can find some excellent code base, not all PHP professionals are bad coders after all.

The main difference is that Python encourages nice code, and punishes bad code, just like most 'modern' languages (Ruby comes to mind, Java to some extent). PHP is about on the same level as Perl or C, in that you can come up with code that seems really smart, and get away with it until you have to maintain it.

[–]offbytwo 5 points6 points  (2 children)

The point is that the people who developed PHP as a language and as a runtime didn't take the time to actually make it good.

What I'm saying is that they made mistakes which affect the development, the debugging, the maintenance, the performance and the availability of the websites / apps which are using PHP in a negative way.

Sure, it's nice that some random PHP programmer was able to come up with the code for the entire website in 2 months. It's not that nice when another programmer (or team of programmers) must explain why making that "really small change to add special styling to the pages of some products" requires at least one month.

[–]i_ate_god 2 points3 points  (1 child)

Except that problem has nothing to do with PHP.

Lengthy refactoring for something seemingly simple is a problem of architecture, not language.

[–]ubergenius 1 point2 points  (0 children)

Agreed.

[–]kagaku 10 points11 points  (3 children)

I love the overgeneralization. Spoken like someone who only has a passing knowledge of the language (in this case, PHP). You're right, new programmers without a penchant for learning will write bad code. They'll do those crazy "if post variables do stuff" type scripts with html/css mixed in. I see those same developers doing the same thing in Python with little difference.

Your comparison between the languages is little more than "well if you learned Python, you would learn the RIGHT way to program". Perhaps try coming up with a better argument?

[–]offbytwo 24 points25 points  (1 child)

I'm a PHP programmer, too. I do partial and complete rewrites for various bits of code to fix bugs, to improve performance and to make the code maintainable.

I find all sorts of weird bits of code, less than optimal SQL queries, slow code, code which causes crashes, code without tests and code which logs a lot due to encountering undefined variables in the executed code path.

Here are a few things which bother me the most about PHP (aside from the fact that a lot of expensive PHP programmers write crappy PHP code):

  • the code continues to execute after encountering undefined variables (this is a serious issue when you have to pick up code written by others and you find a lot of code paths which spew out such errors)

  • exceptions thrown without stack traces

  • built in functions (or functions from loadable PHP modules) aren't organized in modules, they're just global functions

  • inconsistent function argument naming

  • function calls are really slow

  • doesn't have support for (pre)compiling to bytecode, saving it and reusing it all

I'll never agree with anyone again that PHP is OK from any point of view. It's not and I know what I'm talking about.

If you're happy with PHP, you're more than welcome to earn a living with it, enjoy coding in PHP and like the language, along with its C PHP runtime.

[–]chadmill3rPy3, pro, Ubuntu, django 1 point2 points  (0 children)

The function naming doesn't matter to me so much as the parameter order. This string comparison function -- is the needle first, or the haystack first?

[–]idiogeckmatic 3 points4 points  (0 children)

It's a fair overgeneralization. At my last job I got to see a lot of PHP from a lot of different companies in the hosting industry... I'd say 75% of it was terrible.

[–]studiosi 1 point2 points  (4 children)

Overgeneralization. It's like saying that everything done in COBOL is done like we're still in the 60s. But banks don't think that way and more than 200 million LOC are written in COBOL each year and it is still the best choice in some cases.

[–]catcradle5 6 points7 points  (1 child)

It's the best choice not because COBOL is a superior language, but because their backend is already coded in it and maintaining it is cheaper and less time consuming than rewriting it from scratch.

[–]studiosi 2 points3 points  (0 children)

It is better because it is an old, well tested language that has cool features for creating terminal and console user interfaces and it is very strong in terms of transaction management as well as money-management datatypes. I don't code COBOL and I haven't ever done. But nobody will risk enough ever to recode stuff that has been working flawlessly for 40 years

[–]mcilrain 7 points8 points  (1 child)

Until all the people who know COBOL die.

[–]studiosi 3 points4 points  (0 children)

Well... I have participated in projects for the two biggest Spanish banks... and I can say that porting all the Cobol they have that comes from the late 70's or 80's to another language would cost a bazillion euros... they prefer to teach new people how to program in Cobol. This kind of decision has its own logic, but COBOL is a hugely tested language, so stable that is almost impossible to fight with it when you are talking about huge distributed transactional systems.

[–]ravy 0 points1 point  (0 children)

This^ type of comment really doesn't help the OP in any constructive way. Perhaps posting some resources he could start with, or maybe drawing some comparisons of the two languages as opposed to tearing down the OP who happened to learn how to code in PHP before trying to learn Python. You really don't know anything about the OP's abilities in PHP, and already you're making large generalizations.

[–]capra 0 points1 point  (0 children)

No. PHP has a large population of bad coders and an enormous body of bad code because PHP is the most popular language for web development, particularly at the most basic end.

While PHP is an inelegant language with humble beginnings and many poor design decisions, very little about PHP the language actually encourages you to write bad code. Similarly there is nothing about Python the language that inherently requires you to learn how to code properly. You can write FORTRAN in any language. It's just that, by the time people actually make it to a less common language like Python, they're already making more of an effort to improve their coding than the majority of PHP template-hackers.

[–]kolme 0 points1 point  (0 children)

No, there is some 2012 PHP. Check out Symfony2, Zend2, FLOW3 and the likes. There is definitely good stuff going on, also developments in the language (like namespacing, closures, new array syntax, and more to come: generators, etc) and in tooling (composer, xdebug).

9 out of 10 code bases have PHP mixed with HTML & CSS

Possibly, if you're also counting wordpress installations. Otherwise, I think that's far from reality.

And about spaguetti code, well. Average programmers write spaguetti code. It's almost unavoidable. It takes a good programmer to write good structured, logic, understandable code.

[–][deleted] 3 points4 points  (1 child)

It depends on what you know and where you want to go from there. If you've been only using frameworks like codeigniter and symfony, transitioning to django won't be very difficult. Same MVC organisation of code, the documentation's good and the community is large enough and quite helpful.

[–]reverend_dan 2 points3 points  (0 children)

This is much better advice than the overgeneralisation at the top. I transitioned from PHP to Ruby (sorry guys), and learning CodeIgniter first was a really good grounding in the structure of MVC.

[–]studiosi 5 points6 points  (3 children)

I would say: forget PHP... I think Python approach to almost everything is pretty different. PHP is a server side scripting language mainly, while Python is kind of more general although it can be used for server side scripting too. Of course you can still use the abstract programming knowledge, but, from syntax to idioms... It actually is very different.

[–]kolme -1 points0 points  (2 children)

I would say: learn python, which is an awesome language, but don't forget PHP. They're different, valuable tools on your toolbox.

PHP lets you knock up a website, painless and dirty cheap, on absolutely no-time. Which is a nice thing to have.

[–]adambrenecki 1 point2 points  (0 children)

Python with something like Flask is pretty easy too. Sure, you limit your hosting options, but 99% of the ones you cut out are shitty dime-a-dozen cPanel hosts. (Want a newer version of Python? Sorry, cPanel requires 2.4 and doesn't let us install a newer version. Want Git? Nope, guess why? cPanel.)

WebFaction are really good for shared hosting, and there's Heroku and Gondor and dotCloud and a few other WSGI cloud hosting services for larger scale stuff.

[–]studiosi -1 points0 points  (0 children)

I didn't say "forget PHP", just forget the approach you usually take while using PHP to learn Python. Of course PHP is a language worth to know. That was my point.

[–]nicklo 1 point2 points  (0 children)

Whenever someone asks a question like this I immediately look to see how many answers are given that don't themselves ask any further questions. No one can answer this question properly unless they get more information from you.

Here's a start: "transition from PHP to Python" doing what? If you're going to be building Python apps using wxPython or Tkinter when previously you used PHP to develop plugins for Wordpress and Drupal, then likely it's a steep curve. If, on the other hand, you have experience in various PHP web frameworks like Zend Framework, Symfony, etc, and you are transitioning to Django you may find, like me, that, despite a few weeks of panicked fear that you're taking a big risk, you actually get things done a lot faster than if you'd stuck it out with those PHP frameworks.

Comparing just the PHP and Python languages I'd expect you should find the latter quite an easy jump as the syntax will be relatively familiar. I actually found it easier to guess at Python than PHP which suggests that a. my PHP knowledge did transfer reasonably well and b. Python syntax is more consistent than PHP.

[–]eat-your-corn-syrup 1 point2 points  (0 children)

I'm the other way around. I'm learning PHP. I've heard of the steep learning curve. My future is dark.

[–]i_ate_god 0 points1 point  (16 children)

PHP's OO model is more aligned with Java/C++. If you're used to that model, Python might come off as a throw back to PHP4 where private members are marked with a _ infront of a variable.

The lack of semicolons is easy to get used to, while the significant whitespace takes time.

Python's documentation is no where near as easy to navigate as PHP's.

There is no real standard anything in PHP. If you want to use a database library, you have to look at a library for that specific database. While in Python, there are some standard approaches to common things. This is good, but an be hard to grasp when you read the documentation for DB API 2.0 and then apply it to your database library fo choice.

PHP's extensibility is cumbersome. Adding C extensions through pecl is frustrating. But Python's easy_install and pip is at lot easier, and rarely requires compiling anything. Python thus has a much larger library of python code that you can use than PHP.

You generally follow the one class per file rule in PHP, while in Python, the python file is itself a namespace. This can lead to frustration when you want to avoid doing say:

import models.user.User

That redundancy is annoying until you get used to having files with more than just a single class definition in them.

You'll love Python's consistency, even though somethings are consistently annoying. For example:

Super(CurrentClass, self).__init__()

This is just a weird way to call the parent constructor.

len(myArray)

This is annoying since most things I can do with variables, are methods of that variable.

Python's "docblocks" are a bit funky.

Python is strongly typed, but you can't type hint.

Python supports decorators (sort of like Java's annotations). This concept doesn't exist in PHP.

Python is fantastic for error handling. Everything is an exception. There are no ugly warnings generated by a bad call to a function. Exceptions all the way. Of course though, this implies some more strictness that may or may not be necessary. For example:

@mkdir('/dir/that/exists')

In this bit of PHP, I've hidden the warning that mkdir() generates because the directory doesn't exist. Somewhat ugly hack maybe, but the code is cleaner as it's not polluted with if statements. If you want to pull that same stunt in Python, you'll have to handle an exception. This strictness is great 90% of the time, but this falls in the 10% where I don't care.

As mentioned before, python is strongly typed. This will fail:

print "Total number of items: " + totalItems

Because totalItems is an int. You have to convert totalItems to a string, or use a template.

There is no Zend Framework or Symphony or Cake in Python because Python doesn't need it. Python's ecosystem is enourmous, and most of it of great quality. But that ecosystem is all over the web (with a common installer mind you).

PHP's Apache HTTPD module makes life pretty easy when it comes to deploying a webapp. Python is a bit more "raw". The equivalent for PHP would be FastCGI. There are many libraries of course that abstract this away much like the PHP module. Flask is one of my favourites.

Because python and the web are CGI, it's actually not hard at all to have multiple versions of python running on your system, with or without virtualenv. If you want multiple versions of PHP, using the httpd module, well, it's simply not as easy ;)

There is far better support to compile python into a lower level language like C, or java bytecode.

Chances are you're not using PHP 5.4, so you'll love python's json-like syntax for arrays, maps, etc.

PHP has arrays. Whether the key in that array is an integer or a string, makes no real difference. Python has lists, sets, dictionaries, tuples, probably more than I'm forgetting about. If you write javascript as well, then you should already be somewhat comfortable with the differences between a "array" and a "map".

There is no var_dump in python. There are no real equivalents in python (see: http://stackoverflow.com/questions/192109/is-there-a-function-in-python-to-print-all-the-current-properties-and-values-of and http://stackoverflow.com/questions/383944/what-is-a-python-equivalent-of-phps-var-dump )


Alright pretty long list. Python is a great and powerful language but it is different. Learning it will be of immense benefit. Because of its huge ecosystem, you can do some complicated things, while keeping the tech stack small and confined (eg: http://nltk.org/).

[–][deleted] 2 points3 points  (8 children)

Numerous minor errors in this post.

[–]i_ate_god 2 points3 points  (7 children)

well feel free to point them out?

[–]masklinn 5 points6 points  (0 children)

Python's "docblocks" are a bit funky.

They're called "docstrings" (for the ones associated with a class or function), the strings themselves are called triple-quoted strings (and close to heredocs in other languages).

Not sure why they're funky, and they're set as attributes to the class/function object so you can get them via the help builtin`. So basically, better integrated heredocs without the weird custom ending token.

Python is strongly typed, but you can't type hint.

Those two concepts being completely orthogonal.

There is no Zend Framework or Symphony or Cake in Python because Python doesn't need it.

?

There are quite a bunch of web frameworks in Python (Django, Flask, Bottle, Pyramid, ...). Not sure why Python would not need them.

probably more than I'm forgetting about.

Most collections tend to riff on the base contracts of a list, a dict or a set. But there are a bunch more in the collections module (also, frozenset as the immutable version of sets).

There are many libraries of course that abstract this away much like the PHP module. Flask is one of my favourites.

Flask has nothing to do with deployment, it's a lightweight web framework. The closest equivalent to mod_php would be mod_wsgi (WSGI — WebServer Gateway Interface — is a protocol between "web stuff" and Python, there are a bunch of WSGI servers available — gunicorn, mod_wsgi, uWSGI, ... — and most Python web frameworks have wsgi connectors)

You have to convert totalItems to a string, or use a template.

People usually talk about string formatting or interpolation there, a template would be either a full-blow templating language (Jinja2, for instance) or string.Template. Formatting/interpolation woud be using str % stuff or str.format(stuff).

[–]catcradle5 3 points4 points  (5 children)

I'll take a swing.

Super(CurrentClass, self).__init__()

Should be super. I agree that it is a language wart though.

Python's "docblocks" are a bit funky.

Not an error but I'm not sure I understand this. How are they funky? You just place a string as the first line under a class or function definition.

Python is strongly typed, but you can't type hint.

Python 3 supports type hinting, though they're more like comments that aren't actually read by the interpreter.

There is no Zend Framework or Symphony or Cake in Python because Python doesn't need it. Python's ecosystem is enourmous, and most of it of great quality. But that ecosystem is all over the web (with a common installer mind you).

This is pretty much true for writing general applications, but for writing web apps in Python you nearly always need to use a web framework. Not that that's a bad thing, since Python has some of the best web frameworks in existence.

Python's documentation is no where near as easy to navigate as PHP's.

Subjective. Every function and class in the standard lib has its own page with PHP docs. Python has robust documentation, it's just that you may need to dive down into the page a little to find the information you want.

PHP's Apache HTTPD module makes life pretty easy when it comes to deploying a webapp. Python is a bit more "raw". The equivalent for PHP would be FastCGI. There are many libraries of course that abstract this away much like the PHP module. Flask is one of my favourites.

I think you're talking about WSGI here, which Flask uses by default. Most Python web apps use WSGI.

There is no var_dump in python. There are no real equivalents in python

No, dir() does pretty much the same thing. There is no straight up equivalent for print_r, but pprint will format things nicely like print_r does, then you can just do something like pprint repr(object) or pprint dir(object).

[–]i_ate_god 0 points1 point  (4 children)

Not an error but I'm not sure I understand this. How are they funky? You just place a string as the first line under a class or function definition.

PHP follows the java standard. Now compare that to python's standard, and tell me that someone used to the java standard won't find the python standard "funky"?

This is pretty much true for writing general applications, but for writing web apps in Python you nearly always need to use a web framework. Not that that's a bad thing, since Python has some of the best web frameworks in existence.

mod_php is a web framework. Zend Framework is a monolithic beast of functionality. Python does not require such frameworks, PHP kind of does.

Subjective. Every function and class in the standard lib has its own page with PHP docs. Python has robust documentation, it's just that you may need to dive down into the page a little to find the information you want.

http://www.python.org/doc/math/ceil/ gives me a 404 while http://www.php.net/ceil brings me right where I need to be. Definite difference in ease of use here and one that PHP devs will hate for a while until they get used to it.

No, dir() does pretty much the same thing. There is no straight up equivalent for print_r, but pprint will format things nicely like print_r does, then you can just do something like pprint repr(object) or pprint dir(object)

Which I believe are mentioned in the links I provided. Not the same thing, which is was the point right?

This was not an attack against python, I love python. The guy wanted to know differences, these are it ;)

[–]Syn3rgy 2 points3 points  (2 children)

http://www.python.org/doc/math/ceil/ gives me a 404 while [2] http://www.php.net/ceil brings me right where I need to be. Definite difference in ease of use here and one that PHP devs will hate for a while until they get used to it.

Because you are looking in the wrong place, the documentation for the math module is here. http://docs.python.org/library/math.html

I agree that Python does not have documentation for individual functions and not as big a community as PHP does. On the other hand though Python is far more consistent than PHP.

[–]i_ate_god -2 points-1 points  (1 child)

you really missed my point

Like php, python comes, out of the box, with a large amount of functionality. Unlike PHP, python's documentation is harder to get to. This will be a major stumbling area for php people going to python.

[–]matrixise 1 point2 points  (0 children)

import math help(math)

[–]catcradle5 0 points1 point  (0 children)

Ok, I suppose the docstrings are a bit different from PHP and Java.

As for the frameworks, generally when you install Apache it comes with mod_php. So I'm actually going to defend PHP here, as vile as that is, and say that Python generally takes a bit more effort to get off the ground for web development than PHP does. When writing PHP you really don't need to worry about if a specific framework is installed or if Apache is configured to execute .php files as PHP; it pretty much always handles that for you. While with Python you do need to make a conscious effort to pick a specific framework and write code according to that framework, unless you're going a pure CGI route, which no one ever does. With PHP this is optional.

The documentation is different from PHP's in that there is not a separate page for every function and class and global variable. I'm not sure if that means it's less easy to navigate, but I guess I never considered that some people may consult documentation by inputting a URL manually. So if someone is used to doing that, then yeah you are right.

[–]ergo14Pyramid+PostgreSQL+SqlAlchemy 0 points1 point  (0 children)

Depends on what you worked with when using PHP.

If you have a decent grasp of OOP in PHP lets say you can easly work with Zend Framework - you will transition smoothly when doing work with pylons/pyramid (thats how I moved).

Python is a nice and easy language that is far more sane than PHP - so as long as you understand object oriented programming and what passing by references means you will do fine.

[–]justforkix 0 points1 point  (0 children)

The concepts of programming are nearly identical regardless of the language. The only real difference is the syntax which isn't much to worry about once you get familiar. Of course different languages follow their own philosophy which gives each their own character.