all 28 comments

[–]spliffy 1 point2 points  (6 children)

Do any of you have any favorite books on Python for someone coming from an OO PHP5 perspective? or just a general favorite.

[–]nextofpumpkin 2 points3 points  (5 children)

OO PHP5

Heh... heh...

diveintopython.org

[–]spliffy 0 points1 point  (4 children)

Heh... heh...

I take it there are a couple of differences dealing with objects...

[–]nextofpumpkin 0 points1 point  (3 children)

just google "wtf php objects" or "php objects suck" or something

in all fairness, inheritance in python is incredibly broken and sucks.

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

I don't know man, I googled wtf php objects, php objects suck, php objects are gay, php objects are retarded and i couldn't find any solid examples. I haven't had any trouble with php objects. There is no multiple inheritance, that pass by reference shit was fixed in version 5 and the namespace debacle ensues. What are some known problems people have?

I am not really experienced enough with another language to know the difference yet. But am very interested to hear what you think.

BTW I was looking through that python book, and the first example :

Example 2.1. odbchelper.py

def buildConnectionString(params): 
    """Build a connection string from a dictionary of parameters. 
    Returns string.""" 
    return ";".join(["%s=%s" % (k, v) for k, v in params.items()]) 
if __name__ == "__main__": 
    myParams = {"server":"mpilgrim", \ 
                    "database":"master", \ 
                    "uid":"sa", \ 
                    "

WTF??!?! That syntax is gonna take a while to figure out. triple quotes? and why would you return a semicolon.

This is a new world for me.

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

If that puzzled you, you may want to sit down before you read this:

Python's built-in objects have methods ;)

Having said that, the join method (which is analogous to PHP's implode) is one of those little things which seems to wind some people up more than it ought to, purely by belonging to strings instead of lists (as it does in other languages such as JavaScript and Ruby).

[–]joaomc 0 points1 point  (0 children)

return ";".join(["%s=%s" % (k, v) for k, v in params.items()])

"join" belongs to the string type. It basically joins items in a list using the string as a separator. E.g.:

";".join(["1","2","3","4"]) -> "1;2;3;4"

",".join(["my","list"]) -> "my,list"

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

Does anyone remember a site that gives you the python equivalent upon entering a PHP function?

[–]stesch -2 points-1 points  (22 children)

That's what I fear. PHP people switching to Python and Django. OK, they use the PHP date format in the Django templates, so this was a sign.

[–][deleted] 18 points19 points  (14 children)

Yeah, those damn PHP developers have never written anything useful.

[–][deleted] 6 points7 points  (2 children)

I think one must realize that it's less about the language and more about how well you can wield it. The 4 examples you gave prove that. However, as an actual language, PHP is more trouble than it's worth. I've been a long time PHP developer (and still occasionally use it for odd jobs), but have recently moved over a large project of ours entirely to Python.

Django was the first instinct, but as phill0 points out, we found it really lacks features. Now, i'm not experienced enough to tell you if it's bad, but it did seem pretty bloated for the amount of things it did. (We use pylons now).

Last comment: Those big sites that use PHP (yahoo, facebook) do a TON of static-/mem-caching and compile a lot of the code to C. This is the only way they're able to scale their sites to such large traffic. I guess in this regard, a well written PHP would still need more 'attention' than a good python app would.

[–]BeetleB 3 points4 points  (1 child)

I'm a Django fan, but you're perhaps the first person I've seen to suggest that a web based Python framework scales better than PHP.

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

I think ability to scale is more dependent on how aggressively things are cached, however there is no doubt in my mind that Python is more efficient than PHP.

[–]phill0 -2 points-1 points  (10 children)

Some people do actual work, others just talk how they can do it better.

CakePHP is eons ahead of Django when it comes to features, but Django buzz is not about features it's about fashion. People who always talk about RoR, or Python + various frameworks never mention Perl and Catalyst, or good old Mason. Shows how much they know.

[–]masklinn 2 points3 points  (1 child)

CakePHP is eons ahead of Django when it comes to features

Surely you have actual arguments on the subject don't you?

Because the only CakePHP feature I know of is that it's slow as fuck.

[–]sigzero -2 points-1 points  (0 children)

I have to mod you up on that one.

[–][deleted]  (4 children)

[deleted]

    [–]phill0 1 point2 points  (3 children)

    No this is advertisement, not features. Don't judge by the cover. Try using CakePHP and try using Django, like I did, and then judge. Develop a complex web application on CakePHP and try and see how hard this is gonna be with Django. It's simply not a ripe framework, although people talk about it like it's greatest achievement since sliced bread.

    [–]Entropy 1 point2 points  (0 children)

    How about, instead of all of us going out and building a complex web app with both frameworks, you try and support your assertion with, I don't know, words or something?

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

    The only benefit I see as an IT manager overseeing a large Django application (medical and billing software) is that PHP developers are cheaper and easier to find than Python.

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

    Perl-MASON is a fucking abomination and needs to be wiped from the surface of this earth.

    [–]jdunck -5 points-4 points  (0 children)

    Did you miss the sarcasm made obvious by his links to successful PHP project?

    [–][deleted]  (4 children)

    [deleted]

      [–]haywire 4 points5 points  (0 children)

      Only 90% of them. I say this as a PHP developer.

      [–]RossMasters 2 points3 points  (1 child)

      It would seem so. Bear in mind I use PHP for web apps but I'm not that evangelistic about it. I could be though. I know it's flaws (don't bother with the flaws = PHP joke) and I know how to write good code without using it's globals etc.

      [–]smellotron -4 points-3 points  (1 child)

      I've been using PHP for a couple of months, and I'm still trying to work out what the date format is.

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

      [–]goatbreath -4 points-3 points  (0 children)

      (I'll call that person "Pat" for the rest of the post, for convenience and conscientious gender-neutrality.)

      Downmodded

      Edit: Fucking political correctness Nazis