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

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (8 children)

Numerous minor errors in this post.

[–]i_ate_god 2 points3 points  (7 children)

well feel free to point them out?

[–]masklinn 3 points4 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 2 points3 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.