Slashdot Mirror


Python in a Nutshell

Ursus Maximus contributes this review of Python in a Nutshell, writing "Perhaps the best book about Python ever written, this is the perfect capstone to anyone's library of Pythonic books, and also the perfect introduction to Python for anyone well versed in other programming languages. For newbies to programming, this would still be a good second book after a good introductory book on Python, such as Learning Python by Mark Lutz." Read on for the rest of his review. Python in a Nutshell author Alex Martelli pages 636 pages publisher O'Reilly rating Excellent, superb, 5 stars reviewer Ron Stephens ISBN 0596001886 summary Complete reference book for the Python programming language

Written by my favorite author and Pythonista, Alex Martelli, this book manages to fill three roles in extremely pleasing fashion. First and foremost to me, it is a great read, straight through. Mr. Martelli's prose is always sparkling and always keeps the reader interested. No matter how many Python books you have read, you will learn some nuances from this book, and it is about the best review of the whole Pythonic subject matter that I can imagine. While there is absolutely no fluff whatsoever in these 636 pages, it still makes for rather easy reading because the explanations are so clearly thought out and explored as to lead one gently to understanding, without in any way being verbose. It is obvious that Alex Martelli took his time and put in sufficient thought, effort, and intellectual elbow-grease to make this work a classic for all time.

Secondly, this book is the ultimate Pythonic reference book, the best fit to this role I have yet seen. You will keep this book in the most cherished spot on your book shelf, or else right at your side on your computer desk, because you can almost instantly find any topic on which you need to brush up, in the midst of a programming project.

Third, Python in a Nutshell is the most up-to-date book on Python (as of April 2003) and includes the best and most complete expositions yet on the new features introduced in Python 2.2 and 2.3. These topics are not only covered in depth, they are integrated into the text in their proper positions and relationships to the language as a whole. They are explained better here than I have seen anywhere else, so much so as to make them not only understandable to me (a duffer), but indeed so that they appear seamlessly Pythonic, as if they had been a part of the language since version 1.0. Topics explored in depth include new style classes, static methods, class methods, nested scopes, iterators, generators, and new style division. List comprehensions are made not only comprehensible but indeed intuitive.

The book is surprisingly complete. It covers the core language as well as the most popular libraries and extension modules. It is difficult to choose any one portion of the book to highlight for extra praise, as all topics are treated so well. It is a complete book, the new definitive book about Python.

Everything about this book speaks of quality. In addition to the top notch writing and editing, O'Reilly really did the right thing and published this book printed on the highest quality paper, paper so thin that the 636 pages are encompassed in a book much thinner than one would expect for such a size, but strong enough to resist wear and tear. The text is most pleasing to the eye. Holding the book, and turning its pages, gives one a feeling of satisfaction.

Any job worth doing is worth doing well. Alex Martelli and O'Reilly have done justice to a topic dear to our hearts, the Python programming language. Perhaps, in years to come, the passage of time may make this book to be no longer the most up-to-date reference on the newest features added to Python. But time can not erase the quality craftsmanship and the shear joy of reading such a well thought out masterpiece of Pythonic literature.

You can purchase Python in a Nutshell from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page. Ron Stephens would also like you to check out Python City, with "27+ reviews of books about Python. 67+ links to online tutorials about Python and related subjects Daily newsfeed of Pythonic web articles, new sourceforge projects, etc."

189 comments

  1. Nutshell?!? by skillet-thief · · Score: 5, Funny
    634 Pages!?!

    That's a pretty goddam big nutshell, if you ask me!

    --

    Congratulations! Now we are the Evil Empire

    1. Re:Nutshell?!? by wisdom_brewing · · Score: 0

      634 pages?

      can type but still cant read...

    2. Re:Nutshell?!? by 0x00000dcc · · Score: 1
      634 Pages!?! That's a pretty goddam big nutshell, if you ask me!

      Or some pretty big nuts.

      We learned bits and pieces of Python in an Imperative Languages course I took for my CS degree. Enjoyed it, the very little that we covered. I wish the prof had paid more attention to Python than Pascal for that course, but Pascal was his favorite, so that idea got shot down quick ...

      --

      -- (Score:i, Imaginary)

    3. Re:Nutshell?!? by skillet-thief · · Score: 1

      I thought I'd give 'em the benefit of the doubt.

      --

      Congratulations! Now we are the Evil Empire

    4. Re:Nutshell?!? by sporty · · Score: 1

      Any smaller, the ASPCA would bitch :)

      --

      -
      ping -f 255.255.255.255 # if only

    5. Re:Nutshell?!? by sporty · · Score: 1

      To hold a python? The ASPCA would have a fit if you used a normal sized nutshell. :)

      --

      -
      ping -f 255.255.255.255 # if only

  2. Gentoo Zealot translator! by Anonymous Coward · · Score: 2, Funny
    Official Gentoo-Linux-Zealot translator-o-matic

    Gentoo Linux is an interesting new distribution with some great features. Unfortunately, it has attracted a large number of clueless wannabes who absolutely MUST advocate Gentoo at every opportunity. Let's look at the language of these zealots, and find out what it really means...

    "Gentoo makes me so much more productive."
    "Although I can't use the box at the moment because it's compiling something, as it will be for the next five days, it gives me more time to check out the latest USE flags and potentially unstable optimisation settings."

    "Gentoo is more in the spirit of open source!"
    "Apart from Hello World in Pascal at school, I've never written a single program in my life or contributed to an open source project, yet staring at endless streams of GCC output whizzing by somehow helps me contribute to international freedom."

    "I use Gentoo because it's more like the BSDs."
    "Last month I tried to install FreeBSD on a well-supported machine, but the text-based installer scared me off. I've never used a BSD, but the guys on Slashdot say that it's l33t though, so surely I must be for using Gentoo."

    "Heh, my system is soooo much faster after installing Gentoo."
    "I've spent hours recompiling Fetchmail, X-Chat, gEdit and thousands of other programs which spend 99% of their time waiting for user input. Even though only the kernel and glibc make a significant difference with optimisations, and RPMs and .debs can be rebuilt with a handful of commands, my box MUST be faster. It's nothing to do with the fact that I've disabled all startup services and I'm running BlackBox instead of GNOME or KDE."

    "...my Gentoo Linux workstation..."
    "...my overclocked AMD eMachines box from PC World, and apart from the third-grade made-to-break components and dodgy fan..."

    "You Red Hat guys must get sick of dependency hell..."
    "I'm too stupid to understand that circular dependencies can be resolved by specifying BOTH .rpms together on the command line, and that problems hardly ever occur if one uses proper Red Hat packages instead of mixing SuSE, Mandrake and Joe's Linux packages together (which the system wasn't designed for)."

    "All the other distros are soooo out of date."
    "Constantly upgrading to the latest bleeding-edge untested software makes me more productive. Never mind the extensive testing and patching that Debian and Red Hat perform on their packages; I've just emerged the latest GNOME beta snapshot and compiled with -09 -fomit-instructions, and it only crashes once every few hours."

    "Let's face it, Gentoo is the future."
    "OK, so no serious business is going to even consider Gentoo in the near future, and even with proper support and QA in place, it'll still eat up far too much of a company's valuable time. But this guy I met on #animepr0n is now using it, so it must be growing!"

    -

    1. Re:Gentoo Zealot translator! by n1cad · · Score: 0, Offtopic

      best. post. ever

    2. Re:Gentoo Zealot translator! by monsterzero2002 · · Score: 0, Offtopic

      My career was going no where until Gentoo, now I get a job offer a day, at least. My programmer friends look at me with new respect. They know I have taken the right step, and that they soon will too. As for Python, I am convinced it is less powerful than XLANG, which I do everything in now, since it supports dynamic macros and XML. Thank you slashdot!

    3. Re:Gentoo Zealot translator! by Anonymous Coward · · Score: 0
      Whoever wrote that is a GENIUS!

      Some notes for improvement:

      Gentoo users use fluxbox a ton, not so much blackbox.

      .....I've just emerged the latest GNOME beta snapshot and compiled .....

      Gentoo users LOVE KDE. Probably change Gnome to KDE 3.2.0.1.5 or whatever ridiculously up-to-date version number it is.

      Just some thoughts.

  3. Where's the review? by campbellkid · · Score: 5, Insightful
    The reviewer assumes either that we have already read one of the earlier editions, or that we can read his mind. Asside from the discussion about how nice the paper is, I don't know what sets this book apart from other Python books.

    Could the author please respond in this thread and give some examples of the new content, rather than just "covers it all"?

    1. Re:Where's the review? by josephgrossberg · · Score: 4, Insightful

      Heh. Apparently he was too busy sucking Alex Martelli's c0ck to write any more details.

      I mean Martelli's the man and all, but don't drop shit like:

      * "Perhaps the best book about Python ever written"
      * "my favorite author ... Alex Martelli"
      * "Mr. Martelli's prose is always sparkling and always keeps the reader interested"
      * "It is obvious that Alex Martelli took his time and put in sufficient thought, effort, and intellectual elbow-grease to make this work a classic for all time."
      * "You will keep this book in the most cherished spot on your book shelf"
      * "It is difficult to choose any one portion of the book to highlight for extra praise, as all topics are treated so well."
      * "Everything about this book speaks of quality."
      * "Holding the book, and turning its pages, gives one a feeling of satisfaction."
      * "Time can not erase the quality craftsmanship and the shear joy of reading such a well thought out masterpiece of Pythonic literature." ... under the premise of objectivity.

      People want to know "What's good and bad about this book" and not "How many ways can I kiss ass".

    2. Re:Where's the review? by Anonymous Coward · · Score: 0

      Mod parent up! It may be flamebait, but it's sure insightful!

    3. Re:Where's the review? by Anonymous Coward · · Score: 0

      It actually _is_ that good

    4. Re:Where's the review? by josephgrossberg · · Score: 1

      Then why'd you say so anonymously?

    5. Re:Where's the review? by Anonymous Coward · · Score: 0

      This is the first edition. There *was* no earlier edition to read.

      The book is the most up-to-date book available at this time on Python, and since there have been some pretty major changes in the *language* (not the book), it's nice to have one that covers it.

      You ask for specifics on new stuph. The review mentions several:
      "Topics explored in depth include new style
      classes, static methods, namespaces, iterators, generators, and new
      style division. List comprehensions are made not only comprehesible but
      indeed intuitive."

      Note - these are new features of the *language* that are covered in the Nutshell... Of course, if you'd read the review carefully, you'd have figured that out...

      Just my $.03 worth.
      Anna

    6. Re:Where's the review? by aleax · · Score: 1

      Fair enough...! "Unix Review"'s review of the book, found at http://www.unixreview.com/documents/s=7822/ur0303j / , may perhaps prove helpful in this regard. The sample chapter and TOC you can download in PDF format from http://www.oreilly.com/catalog/pythonian/chapter/c h04.pdf might also help you get a more detailed idea about the book.

      There were no "earlier editions" of "Python in a Nutshell", by the way; this is the first one.

      --
      Alex
  4. Re:Ya, but does it make julian fries? by ForteTuba · · Score: 1

    No, but it does handle julian calendars: http://www.pauahtun.org/julian_period.html

  5. And now for something completely different... by WIAKywbfatw · · Score: 3, Funny

    You know, when I saw that title, I just knew that there was a joke in there involoving Monty Python, nuts and hell (nutshell, nuts hell).

    If I had the time I'd come up with it, and I'm sure it would be the funniest joke in the world, much better than the German joke, "two peanuts were walking down the street and one was assorted".

    Unfortunately, I have to go out for a silly walk, and then onto a mouse club, so I'll have to leave it to someone else to inject some much needed hilarity into these proceedings.

    --

    "Accept that some days you are the pigeon, and some days you are the statue." - David Brent, Wernham Hogg
    1. Re:And now for something completely different... by wirde · · Score: 1
      Not so far fetched, since the name of the language does come from Monty Python.

      I am sure the joke should involve coconuts and swallows rather than hell though...

      --
      in GNUin GNUin GNUin GNUin GNUin GNUin GNUin GNUSegmentation fault
    2. Re:And now for something completely different... by liquidsin · · Score: 2, Informative

      "two peanuts were walking down the street and one was assorted"

      I believe you're going for "one was assaulted" (a salted...*zing*)

      --
      do not read this line twice.
    3. Re:And now for something completely different... by iplayfast · · Score: 1

      I kinda liked assorted. It has wordplay. Assorted and assaulted are very close. And when you get assorted nuts it means several kinds. How do you get several kinds of 1?

    4. Re:And now for something completely different... by Anonymous Coward · · Score: 0

      What's the difference between a duck?

      One of its legs is both the same.

    5. Re:And now for something completely different... by Anonymous Coward · · Score: 0

      Just to be absolutely clear, in my memory, the joke was:

      "Two peanuts were walking down the strasse (spelling?). One was assaulted.... peanut."

    6. Re:And now for something completely different... by Raffaello · · Score: 1

      That's:
      "Two peanuts were walking down the Strasse. One was assaulted ... peanut."

  6. A (hopefully) unbiased opinion on Perl v. Python by Anonymous Coward · · Score: 5, Insightful

    Let me start off by saying that I don't usually read this site. I was pointed here by a python programmer who wanted more python people to join this dicussion. However I'm not exactly a "python person." I'm most comfortable in C, with a smattering of Java, Perl, Asm, Lisp and Python (in no particular order). That being clarified, I'd like to say a few words.

    First of all, I don't want to offend anyone, but Perl really is an example of the most horrible way to design a language. I say "design" with tongue-in-cheek, because the language wasn't really designed so much as thrown together from pieces of odd scripting languages (many of which should have been put to rest long ago). The implementation itself is rather unfortunete; because of how it's built you can't really implement perl in terms of itself (well I suppose you could, but not with a slight measure of self-respect), the entire system needs to be scrutinized by security experts before any program written in Perl can be considered secure, and it is doubtful that Perl will ever be re-implemented ever again.

    That being said, Perl is at least useful for many things ("practical," I believe it's called). People always tell me how they use it for system-administration tasks (for some reason I don't seem to engage in enough adminitration tasks to require perl's help, or if I do they're all suitibly mundane), and it does have an impressive ability to cope with string data (not something I'd base a language on, but at least it stopped people from using SNOBOL).

    Now Python on the other hand is almost completely a different story. It's supremely orthagonal and elegant in its design, with support for functions as first-class types, an enforcement of clean coding standards through whitespace sensitivity (most Perl coders object vehemently to this because it infringes on their ability to write really ugly code), etc.

    But the problem is that Python suffers from a lot of Perl's problems and adds a few of its own: you can't implement it in itself, it has no strong typing (even Perl's use strict is ridiculously better), an OO system with no support for data hiding, etc. etc. And that brings me to the biggest problem: Python doesn't really have a niche to fill. The CGI space has been seemingly co-opted completely by Perl (at least until people start using PHP), and it's too dog-slow to be used for real CS applications. As a beginner's language it's ideal, but that's not going to help it be taken seriously when it comes to real computing tasks.

    If the python developers made some tweaks to the type system and added a real compiler, then I would advocate that most software engineering be moved there. As it stands it's an original language which is a lot of fun to program in, and still has lots of unmapped potential to it.

    So where does that leave us, now that I've managed to piss EVERYBODY off? Well, I guess I conclude by saying that if you read this and got a sudden urge to throw a molotov cocktail through my window, then you're really taking one language too seriously. If you blind yourself so much that you can't see the faults in Perl or , then you're really no use to anyone in your community, in particular the users who depend on you to build solid, well-rounded applications. Don't be a Python zealot or a Perl zealot; be a programming zealot, learn as many languages as possible, and which one to use in a given situation. That's all I have to say.

  7. Re:Python == Snake Oil by jejones · · Score: 1
    Python is a hideous kludge...

    As opposed to what? (If you say "Perl" or "C++", you may well have found the fatal joke from the Monty Python sketch.)

  8. An Appropriate Receptacle by ddillman · · Score: 1, Funny

    I mean hey, those guys were off their rockers, all of 'em! Have you seen that Silly Walks bit? And the one where the Society puts things on top of other things? Nuts!

    What? Programming language? Um...

    Nevermind!

    --
    Little girls, like butterflies, need no excuse. -- L. Long
  9. Re:A challenge to smart people... by Anonymous Coward · · Score: 1, Funny

    Actually I looked at this book in the store and it does not seem to have much at all about Python. There are not any pictures, and all the episodes are missing somehow. There is not even anything on Michael Palin, John Gleese or Eric Idle.

    I had a hard time reading the rest of the book as it was about some obscure stuff that no one ever heard of before.

    Other than all that, it is probably a pretty good book for some chaps somewhere to perhaps enjoy.

  10. You ain't seen nothing yet. by GoodFun!!!!!!!! · · Score: 5, Funny

    I got 2 big nutshells for ya, and a python to go with em. If you're lucky, I'll even give you a Perl necklace.

    1. Re:You ain't seen nothing yet. by Anonymous Coward · · Score: 0

      damnit.. don't make me horny while i'm at work.

  11. Perl v. PHP by Anonymous Coward · · Score: 2, Insightful


    The CGI space has been seemingly co-opted completely by Perl (at least until people start using PHP)


    what, PHP doesn't suffer from the same problems as perl? whitespace? data hiding? real objects?

    people use these languages because the fluidity at which they can be written (albeit crappily). conversley, a good programmer will write good code regardless of the pro-active design constraints imposed by the language.

    etc.

    excellent troll btw!
  12. Re:A (hopefully) unbiased opinion on Perl v. Pytho by raju1kabir · · Score: 5, Insightful
    But the problem is that Python suffers from a lot of Perl's problems and adds a few of its own

    The biggest problem with Python, IMHO, is the online documentation. It's the worst I've ever seen, so abstract that it's of no use to anyone except maybe as a reference for someone who wants to write real documentation.

    I can only assume that like Python itself, the documentation is the result of an author who wanted to do things "the best" way, without being willing to look outside his own head to determine what that might be. For the language itself, the result was okay - if slightly annoying at times. For the documentation, it's unacceptable. New and different languages can be learned. But with indecipherable and oddly-organized documentation, that's very difficult to even start doing. I had several "false starts" with Python, abandoning it quickly because the documentation (and installation process) were so opaque. If not coerced by my employer into giving it another try, I never would have touched it again. The only reason I stuck with it this last time was because my employer had a stack of Python books for me to use.

    In the "heavy scripting" domain, I've put a lot of time into Perl, Python, and PHP. PHP's online documentation is the exact opposite of Python's; entirely focused on the practical, with lots of examples and very little theory or background. Perl's is somewhere in the middle. Overall, as a learner I found Perl's documentation to be the best, and as an advanced developer I find PHP's to be supreme, bar none. Python's is a disgrace, useful to neither beginning nor advanced users.

    It's great that people are writing good books about the language. But in this day and age, it shouldn't be necessary to buy a book just to make sense of an open-source tool.

    --
    "Patriotism is your conviction that this country is superior to all other countries because you were born in it." -- GBS
  13. Pet Python problems by Ed+Avis · · Score: 1, Offtopic

    I've been using Python for a few months now. I hope people won't mind if I post a shopping list of what seem to be missing features in the language, and ask if there is a way round them.

    - Python has 'break' and 'continue' like C. But these only affect the innermost loop. Is there a way to break out of an enclosing loop? (In Perl you can label a loop and then say 'next LABEL', etc.)

    - Failing that, is there a way to get goto statements in Python? They can sometimes be an elegant way to express something, contrary to popular myth. (Eg tail recursion.)

    - How can I pass a variable by reference? For example, to take a reference to a string, pass it to a function and have that function modify the string passed in. More generally, is there a way to store references?

    - Python advertises its support for first-class functions, but I can't seem to get closures to work. The 'lambda' keyword won't accept assignment or even sequencing inside the function body. So anonymous functions you might want to pass around can't do much beyond trivial operations. You can get around this to some extent by making named functions in every case and passing those around, but even then they don't seem to act properly as closures, picking up variables from their local scope. (I'm using Python 2.2.1 BTW.)

    - Is there a do/while statement in Python? Plain 'while' is there but occasionally an 'at least once' loop is what you need. Is there an addon package or library for Python that provides a 'do' construct?

    As you may have guessed, these are the things I really miss in going from Perl to Python. The cleaner syntax isn't a big enough payoff for going without some fairly important language features. The project Vyper sounded very promising in its attempt to add real lexical scoping and functional programming features to Python, but it doesn't seem to be active any longer. A real pity. In the meantime, where I have a choice, I'll keep using Perl, despite its syntactic oddities and historical baggage.

    --
    -- Ed Avis ed@membled.com
    1. Re:Pet Python problems by spareparts · · Score: 3, Informative
      The exception mechanism provides a way for you to break out of multiple loops if there is not already an elegant way to express your loop. Also, the else clause for loops can be useful in some cases.

      Objects are already passed by reference. You can't change strings because they are an immutable type. If you need references, you can use the weakref module, or create your own wrapper class (delegating accesses to the underlying object).

      you can define named functions in-line, that work as closures (i. e. using variables from the declaration scope). I've been using Python 2.3, so the change from 2.2->2.3 may have been the change that made this usable. In case I wasn't clear:
      def curry(f, arg):
      def curried(f, *args):
      return f(arg, *args)

      return curried
      do/while is missing. That sucks.
    2. Re:Pet Python problems by skinpup111 · · Score: 1

      - Python has 'break' and 'continue' like C. But these only affect the innermost loop. Is there a way to break out of an enclosing loop? (In Perl you can label a loop and then say 'next LABEL', etc.)

      This can be done easyly by raising a execption. I find it every useful for deeply nested loops.

    3. Re:Pet Python problems by Kidbro · · Score: 2, Informative

      - Python has 'break' and 'continue' like C. But these only affect the innermost loop. Is there a way to break out of an enclosing loop? (In Perl you can label a loop and then say 'next LABEL', etc.)

      Usually solved by a try/except clause when needed - which it seldom is.

      - How can I pass a variable by reference?

      EVERYTHING is a reference. You pass nothing but references. If you call foo(bar), foo will have a reference to the exact same object as bar pointed to. The fact that you can not modify a string passed to a function is because strings are immutable.

      - Python advertises its support for first-class functions, but I can't seem to get closures to work.

      Can't really comment on this I'm afraid. lambdas are very simple, yes. You can define functions within functions - and they will (in 2.2.1) be able to read from, but not write to the name space of the enclosing function, IIRC.

      - Is there a do/while statement in Python?

      No. The Python philosophy is usually "Have one way to do it." do/while doesn't really solve problems a simple while clause doesn't solve. Keep it simple.

    4. Re:Pet Python problems by Frater+219 · · Score: 5, Informative
      Python has 'break' and 'continue' like C. But these only affect the innermost loop. Is there a way to break out of an enclosing loop? (In Perl you can label a loop and then say 'next LABEL', etc.)

      Like Java and Lisp -- and unlike Perl -- Python has exception handling. The structured way to get out of an inner loop is the same as the structured way to get out of a deeply nested function call: raise an exception, and trap it at the higher level where you want to "go to".

      How can I pass a variable by reference? For example, to take a reference to a string, pass it to a function and have that function modify the string passed in. More generally, is there a way to store references?

      In Python, everything is a reference, but strings are immutable objects. There's no such thing as "modifying the string passed in" -- all the built-in string functions return a new string. However, for mutable types such as lists and dictionaries, functions can certainly modify their arguments, as in this example:

      def foo(lst): lst.append("beer")
      y = ["wine"]
      foo(y) # y is now ["wine", "beer"]

      Python advertises its support for first-class functions, but I can't seem to get closures to work. The 'lambda' keyword won't accept assignment or even sequencing inside the function body.

      Especially since I have some Scheme in my programming background, this is a quirk I find annoying about Python: lambda is underpowered. It's comparable to the old BASIC "DEF FN" in that it allows only expressions, not statements, in the lambda-body.

      However, you can do what you want by defining a function with a temporary name, using def, and returning it. (In Python it is perfectly valid to have function definitions inside other function definitions, and it does what you expect: defines functions whose names have local scope, but can be returned.) You can also create callable classes, which act like functions instead of object factories. There's an implementation of curry for instance in the Python Cookbook, which does this. Check it out.

      Is there a do/while statement in Python? Plain 'while' is there but occasionally an 'at least once' loop is what you need. Is there an addon package or library for Python that provides a 'do' construct?

      There is neither a do/while nor a repeat/until in Python. Again this is something I don't agree with, but the argument is that this keeps the number of redundant keywords down. The convention is to use while loops and escape with break when necessary.

    5. Re:Pet Python problems by Anonymous Coward · · Score: 1, Informative

      > - Python has 'break' and 'continue' like C. But these only affect the innermost loop. Is there a way to break out of an enclosing loop?

      You'd use an exception.

      >- How can I pass a variable by reference?

      All variables are passed by reference.

      > For example, to take a reference to a string, pass it to a function and have that function modify the string passed in.

      Strings are immutable so they can't be changed. Your function would return a new string with the new value.

      > - Python advertises its support for first-class functions, but I can't seem to get closures to work.

      Closures with nested function definitely work. Don't use lambda's -- they're an admitted failed experiment.

      > - Is there a do/while statement in Python?

      No. Occasionally missed, "while True:" is a widely used idiom instead.

      Oh, and btw, Python can be written in itself, and it's plenty fast for "real CS". There are tons of free and commercial software written it it. It's niche are projects that want a competitive advantage and long term maintainability.

    6. Re:Pet Python problems by tal197 · · Score: 4, Informative
      Python has 'break' and 'continue' like C. But these only affect the innermost loop. Is there a way to break out of an enclosing loop?
      Throw an exception and catch it whereever. Eg:
      try:
      __while ...
      ____while ...
      ______raise FinishLoop
      except FinishLoop: pass

      How can I pass a variable by reference? For example, to take a reference to a string, pass it to a function and have that function modify the string passed in.
      Everything is always passed by reference. You can't modify a string because strings are immutable.

      The 'lambda' keyword won't accept assignment or even sequencing inside the function body. So anonymous functions you might want to pass around can't do much beyond trivial operations.
      lambda is a short-hand for def. Use that if the body isn't a simple expression:

      def make_print(message):
      __def new_fn(): print message
      __return new_fn
      make_print('Hello')()

      Is there a do/while statement in Python?

      while 1:
      __# Stuff
      __if finished(): break

      Some python tutorials I wrote:

      Python for BASIC programmers
      Writing GTK applications in python

    7. Re:Pet Python problems by frankie_guasch · · Score: 3, Informative

      Like Java and Lisp -- and unlike Perl -- Python has exception handling.

      Perl has exception handling with die/eval. Here is an article about it.

    8. Re:Pet Python problems by Ed+Avis · · Score: 1

      Thank you for your response and to the several others who also replied. I've chosen to reply to yours since it seems the most detailed.

      Exception handling to break out of a loop - hmm, yes, I hadn't thought about that. It does seem a bit OTT to raise and catch an exception just for that - a whole 'try/except' block when a simple 'continue LABEL' would have sufficed - but whatever.

      OK, I think I understand what is happening with strings. If they are immutable then there is no way to implement a function like Perl's chomp() which modifies the string passed in. This is not necessarily a bad thing. But still I would like to pass a reference to a variable somehow, for example saying 'please leave the result in this variable'. That can be done with a reference to the string itself, in a language where strings are mutable, or it can be done with a symbolic reference to the variable name (cf 'set' in Tcl and Perl's typeglobs). It doesn't seem that Python has either of these. I guess the way to have a string 'modified' in a function call is the same in Python as in Java - stick it into a one-element array and pass that.

      I have written some code with nested function definitions, to work around the deficiencies of 'lambda' as you describe. But they didn't work as I expected. For example

      def f():
      x = 50
      def g():
      x = 40
      g()
      print x
      f()

      This prints '50', showing that g() cannot access the variable in its enclosing scope. It's not a closure in the true sense. The only way I could find to make this work was to resort to global variables - gah!

      (FWIW the version of Basic I used did allow arbitrary expressions inside a DEF FN... I've never really liked the dogma that you cannot both return a value and cause a side effect.)

      --
      -- Ed Avis ed@membled.com
    9. Re:Pet Python problems by obsidian+head · · Score: 1
      - Python advertises its support for first-class functions, but I can't seem to get closures to work.
      The reason for this has nothing to do with lambda, and everything to do with not supporting Scheme's environment model. There are two ways to fake closures:
      OOP
      Function attributes
    10. Re:Pet Python problems by obsidian+head · · Score: 1
      Closures with nested function definitely work. Don't use lambda's -- they're an admitted failed experiment.
      I don't agree here. Closures do not work, and will not for the forseeable future. They need to be faked. Nested scope has little to do with anything -- "lexical scope" aka Scheme's "environment model" are what's needed.

      The function attribute method of faking closures isn't so bad, I use it. It would of course be nicer to have a cleaner language, but it's sufficient.

    11. Re:Pet Python problems by smcv · · Score: 1

      Is there a do/while statement in Python?

      The usual idiom seems to be:

      while 1: ...
      if exitCondition:
      break

    12. Re:Pet Python problems by obsidian+head · · Score: 1

      Let me qualify that: Guido called it "nested lexical scope."

    13. Re:Pet Python problems by Frater+219 · · Score: 1
      If they are immutable then there is no way to implement a function like Perl's chomp() which modifies the string passed in.

      That's right. The equivalent in Python is "foo = rstrip(foo)", which does rebind foo to a new string.

      This prints '50', showing that g() cannot access the variable in its enclosing scope.

      What you did was create a new name x, local to the scope of g.

      If what you're after is to retain data among several calls, a class is probably what you want. It can be callable (as in the curry example I cited above) -- Python callable classes are practically a generalization of functions.

      On the other hand, you can do closures in Python. This IBM article discusses some approaches.

    14. Re:Pet Python problems by Billings · · Score: 1

      1,2) Exceptions could solve a lot of your problems here. Most of the goto idioms that I've personally used have exception-based analogues; for example, breaking out of an enclosing loop can be handled by sticking the loop you want to break out of in a try block and throwing an exception when you want to break out. Offhand, however, I don't think that proper gotos exist in python.

      With regard to tail recursion, however - does python not optimize tail calls? I haven't looked, but I would be a bit surprised if it didn't handle most simple cases.

      3) Variable passing seems to work like java - everything is pass by reference except fundamental data types, and strings are handled oddly.

      4) You get closures to work with lambdas by using default values for parameters, and you get around the fact that lambdas are only capable of evaluating a single expression by making that expression a function call. For example, a little function that returns a callback function with the desired parameters could doing something like:

      def make_callback(index,identifier):
      return lambda i=index, id=identifier: select_item(i,id)

      More complex closures with modifiable local state can be accomplished by using the same techniques with defs, using default parameter values to pass in objects containing state information. Simple case:

      def make_counter(start):
      localdata = { "count" : start }
      def counter(data = localdata):
      data["count"] -= 1
      return data["count"]
      return counter

      Cleaner-looking code can be accomplished by putting together a little object that takes in the desired names and values in kwargs and puts them into its __dict__.

      Python's designers apparently do not want lambda spaghetti.

      5) Nope, there isn't.

      I think that Python really hits an ever-so-slightly different niche from Perl, personally. Perl is quick and dirty, and since it has aspects of any programming paradigm you can think of, pretty much anyone can code the way they're used to, no matter what paradigm they come from. Python can also do quick and dirty, but you have to get used to doing it the python way... which can be trying at times. However, due to the rabid simplicity and orthogonality of the python language design, I'd say that it scales much better than I would expect Perl to scale. If you've written something in python and come back to it later to expand it, I doubt you'd find any big surprises.

      So as an added benefit, Python fits in better in the context of a tool to use in larger projects. For glue code to hold together other parts of a project which can't be done in a scripting language, Perl can't hold a candle to Python due to code maintenance issues.

      If you're doing smaller scripts, work alone, and write Perl in a maintainable way (very doable, but almost never seen), however, there's really no compelling reason to change languages.

      It's a shame that Python's limited to the scripting languages domain, however - lots of the design decisions would seem to be an excellent kernel of a more powerful and elegant general-purpose language.

    15. Re:Pet Python problems by Chmarr · · Score: 1

      You can 'fake' 'pass by reference' by passing a list instead. Viz:

      def fn (a):
      _ a[0] = 'Goodbye'

      a = ['Hello']
      fn (a)
      print a # This will print goodbye

      However, it's VERY rare that you need to use pass by reference. Instead, consider using multiple return values.

      (Underscore used to force indentation)

    16. Re:Pet Python problems by tal197 · · Score: 1

      def f():
      x = 50
      def g():
      x = 40
      g()
      print x
      f()

      > This prints '50', showing that g() cannot access the variable in its enclosing scope.
      > It's not a closure in the true sense.
      > The only way I could find to make this work was to resort to global variables - gah!

      That's the intended behaviour. You can make x
      a static variable of f:

      def f():
      f.x = 50
      def g():
      f.x = 40
      g()
      print f.x
      f()

      If you don't want it static, create a new object
      to hold it (or store it on g, etc).

    17. Re:Pet Python problems by Frater+219 · · Score: 1
      Perl has exception handling with die/eval.

      If you're going to use it for that, take a careful look at the documentation for eval: notably, what do you want to do with __DIE__ hooks? There's more than a bit of anti-structured "action at a distance" going on there.

      Something else to note is that Python and Java exceptions work hand-in-hand with the call stack, and provide useful stack backtraces if you bomb out. ISTR backtraces are an extra you have to ask for in Perl -- the Carp module's confess, if I remember correctly. How does that interact with eval? I see caveats.

    18. Re:Pet Python problems by Trifthen · · Score: 1

      Throw an exception and catch it whereever. Eg:

      try: __while ... ____while ... ______raise FinishLoop except FinishLoop: pass

      Dude... that's disgusting, not to mention raping the exception system. Exceptions are meant to handle errors. PHP fixes the break/continue problem by giving those operators a parameter. So if you want to continue 2 loops up, you say "continue 2;".

      Gah. Now I know why I don't use Python.

      --
      Read: Rabbit Rue - Free serial nove
    19. Re:Pet Python problems by nmtratman · · Score: 1
      Exceptions are meant to handle exceptional situations. As defined in the Python Reference Manual:
      Exceptions are a means of breaking out of the normal flow of control of a code block in order to handle errors or other exceptional conditions.
      Errors tend to be the most common exceptional condition that programmers run into. Exceptions allow you to write the inner code as if everything will work. But, exceptions are supposed to be able handle any exceptional condition.

      In the nested while cases above, the FinishLoop exception should only occur very infrequently -- once per entering the whole loop structure, and then only if the while conditions don't fail. The penalities of occassionally raising an exception are not that bad under Python.

      Should you return later, and add another inner loop (either a for-loop or another while loop), then it's quite obvious that the exception will still take you entirely out of the nested loops. Under your PHP example, all your continue statements would have to be adjusted to the correct nesting level. It might be easy to overlook one, possibly causing obscure bugs.

      --
      Car analogies work about as well as a Ford Pinto with a keg of beer in the passenger seat.
    20. Re:Pet Python problems by Anonymous Coward · · Score: 0

      I've been programming longer then most of the /. crowd has been alive. I am currently picking up Python. In fact, I am at this moment taking a break from reading "Python in a Nutshell" ( to read a review of "Python in a Nutshell", go figure!) I find the reliance on a break statement to impliment any type of loop, annoying. The last time I used any non-structured construct was in 1979, when I learned better. When ever I find breaks in the code that I help develop and maintain, I rewrite the offending loops ( usually with a reduction in code size, despite common wisdom). The other thing I find annoying is the inability to use statements as expressions, though this ability, like the break statement, is easily abused. As I have just started reading Martellis book and have as yet not taken Python for a test drive, my opinions might change. I probably can get use to relying on the exception handling mechinism for code structure and I know I will find callable Objects usefull. Maybe I'll also get use to the evil break. BTW, I am currently on page 40. This book wasts no time in getting to the nuts and bolts of Python. It is just what an experienced programmer needs to learn the language.

    21. Re:Pet Python problems by Ian+Bicking · · Score: 1
      In Python, everything is a reference, but strings are immutable objects. There's no such thing as "modifying the string passed in" -- all the built-in string functions return a new string.
      FWIW Guido has said that in Python 3 (still a ways off) that all strings are going to be Unicode, and for binary/byte data they'll be a buffer object (I don't think related to the current buffer object) that will be mutable, since this is typically more useful for byte data. For now strings of bytes and strings of characters are kind of confused.
    22. Re:Pet Python problems by obsidian+head · · Score: 1

      .. and yet another way: IBM article

    23. Re:Pet Python problems by Dom2 · · Score: 1
      You see caveats, I see Exception::Class and possibly also Error.

      -Dom

    24. Re:Pet Python problems by josu · · Score: 1
      Everything is always passed by reference.

      Not true. In Python, functions pass their arguments by value (by copy). The values themselves are references to objects.

    25. Re:Pet Python problems by Peaker · · Score: 1

      How is it "raping the exception mechanism"? Can you point to a case where it could cause a problem or harm readability?

      "continue 2" on the other hand, almost makes me puke, requires a lot more careful tracking of changes in the code, and makes every piece of code tightly-coupled with every other.

      Puke. Now I know why I don't use PHP.

    26. Re:Pet Python problems by fizbin · · Score: 1

      Actually, as of Python 2.2, with nested scopes implemented, g() can really access the variable outside its own scope.

      The problem though is similar to what you alluded to with passing variables into functions and wanting the functions to modify them; when in the inner function you say "x = 50", you're rebinding the local-to-g version of x. The end result is that the outer x is then not repointed to the new object. (See the PEP for why, or look at the appropriate part of the "what's new" document)

      In any case, this will work in Python 2.2, or in Python 2.1 that uses the proper "from __future__" construct:

      def f():
      x = [50]
      def g():
      x[0] = 40
      g()
      print x[0]
      f()

      A possible way to think about this is that in python, assignment is not a setq but rather a defvar.

    27. Re:Pet Python problems by erikharrison · · Score: 1

      Actually Perl has exception handling, and it is not bad. Perl's exception handling suffers from it's elegance in a sense - Perl exception handling was made by overloading the meaning of two operators in a relatively clean way which allowed older programs to throw trappable exceptions with no code changes. It is perfectly backwards compatible. This also means that there is no unified method of sending and trapping exceptions in a Perl program, which is a major issue. But as time progresses I see this being rectified. The Perl 6 project not only has a reasonable exception system, but envy of that system is causing more and more people to adopt it in Perl 5 - expanding the current system culturally rather than programmatically.


      Not perfect, but a long way from "Perl has no exception handling".

    28. Re:Pet Python problems by Anonymous Coward · · Score: 0

      Is there a do/while statement in Python? Plain 'while' is there but occasionally an 'at least once' loop is what you need. Is there an addon package or library for Python that provides a 'do' construct?


      There is neither a do/while nor a repeat/until in Python. Again this is something I don't agree with, but the argument is that this keeps the number of redundant keywords down. The convention is to use while loops and escape with break when necessary.


      while (something):
      do_stuff
      else:
      do_stuff
  14. Re:Python == Snake Oil by B3ryllium · · Score: 1

    I think he's just bitter about the indented code blocks.

    I know tons of people who think that Python is the best thing since sliced bread, though my personal preference leans towards PHP. But then again, I'm only working with web interfaces currently, so (IMO) PHP is a tad better-suited to that.

  15. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Anime_Fan · · Score: 3, Insightful

    Don't be a Python zealot or a Perl zealot; be a programming zealot, learn as many languages as possible, and which one to use in a given situation.

    You have a point there, but I'd put it in a slightly different way. I'd not tell people to learn as many languages as possible, but rather learn programming and its basics (knowing the architecture behind the scenes, the CPU, is really a lot of fun).

    There isn't much point in knowing every programming language, but a much better deal to know the syntax used in those languages. Also, when learning programming it's important to have a certain sense of logic (especially for object-oriented and/or heavily nested functions) because you need to keep things apart.

    Why do you want to learn the syntaxes?
    Let's use me as an example (not a very good one as I don't know very many languages, but I cope)... I've started programming using simple QBasic (where one learnt horrible spaghetti programming since one was 8 yrs old at the time) and Pascal (where I learnt about functions and procedures, something very important for any programmer).
    I've then moved on to C and asm (PIC16F84) where I've learnt about pointer arithmetics, references and the joys of loose pointers.
    I have since then learnt C++ and asp (vbscript/visual basic/com)...
    Later on when you need to use another language (in my case PHP) it's very easyto just utilize the knowledge you already have. For PHP it was just for me to learn how they handled arrays and strings. That's it. All I needed then was a list of functions (php.net is most excellent), because I already knew its syntax (being based on among others C). Macromedia Flash and Javascript (ECMAScript) were also very easy to use...

    That said I know I have to test Python... I've never actually used it, but since they all say it's very nice I should really try it out... ^^

    I hope this was a far too long comment for most people to put up with, but I don't really care.

  16. Re:A (hopefully) unbiased opinion on Perl v. Pytho by tuffy · · Score: 5, Insightful
    And that brings me to the biggest problem: Python doesn't really have a niche to fill.

    In general, I've noticed Python makes writing programs very fast and very easy to modify later to add new features. It takes me a little longer to write equivilent programs in Perl, but the Perl programs probably run a little faster although they take a bit more effort to modify later. Finally, if I really need a program to run very fast, I can port it to C where it'll run extremely fast, but that will naturally take the longest to write and modify.

    Having said all that, I use Python programs for those day-to-day administration duties where plenty of tweaks are required. Python works great for CGIs too, and should scale up to a reasonable load. But, if speed or extreme scalability are a requirement, porting a Python prototype over to C is often a good idea. Still, I have no shortage of tasks that require quick programming but don't require great speed - and Python fits those quite well.

    But if I could compile it to native code, now that would be pretty sweet.

    --

    Ita erat quando hic adveni.

  17. Re:A (hopefully) unbiased opinion on Perl v. Pytho by john_roth · · Score: 2, Informative

    But the problem is that Python suffers from a lot of Perl's problems and adds a few of its own: you can't implement it in itself, it has no strong typing (even Perl's use strict is ridiculously better), an OO system with no support for data hiding, etc. etc

    Actually, one of these is being worked on: There's an active project to write Python in itself. I believe they're taking the same tack as Squeak.

    John Roth

  18. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Anonymous Coward · · Score: 0, Informative

    I would call you a karma whore if you weren't AC. If anybody would like to see the unplagiarized version of this post and the thread it came from Here it is.

  19. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Anonymous Coward · · Score: 1, Insightful

    > Python doesn't really have a niche to fill.
    > ... As a beginner's language it's ideal

    I think you answered yourself here. The very reasons that make Python easy for beginners (clean design, interpreted, simple tasks require minimal effort etc) make it an ideal prototyping language.
    Python is a language whereby you can be running a test implementation of an idea within seconds, rather than minutes. If it's really necessary, you can always move to C/Java/YourPetLanguage for the production version.

  20. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Anonymous Coward · · Score: 2, Interesting

    I couldn't agree more w/ both this post and the one before it. I have yet to find a use for Python that isn't already covered by a language I know (PHP for web apps, Java for more complicated server or GUI stuff), and the few times I have tried to learn more about Python, I run up against the online documentation, which does more to talk about how cool Python is than actually explain how to use it (just like you said - the opposite of PHP's online documentation, which is hands-down superb). This isn't meant to be a troll post, just my experience. Glad to hear I'm not the only developer who has run into those 2 issues w/ using Python (the Why and What, so to speak).

  21. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Cryp2Nite · · Score: 1

    Ok...
    but how did you like the bookreview?

  22. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Anonymous Coward · · Score: 2, Interesting

    I didn't have this experience at all, I found a lot of their documentation very helpful and certainly more helpful than the free documentation on Perl that you can find.

    I didn't have any problem with false starts, I went to the python website one day to check it out and the next day I went to one of the online books about python they linked to and I learned a shitload and within a couple hours I began to appreciate and love Python.

  23. Re:A (hopefully) unbiased opinion on Perl v. Pytho by bbum · · Score: 5, Insightful

    But the problem is that Python suffers from a lot of Perl's problems and adds a few of its own: you can't implement it in itself, it has no strong typing (even Perl's use strict is ridiculously better), an OO system with no support for data hiding, etc. etc. And that brings me to the biggest problem: Python doesn't really have a niche to fill. The CGI space has been seemingly co-opted completely by Perl (at least until people start using PHP), and it's too dog-slow to be used for real CS applications. As a beginner's language it's ideal, but that's not going to help it be taken seriously when it comes to real

    Uhh.... you are seriously misinformed.

    data hiding: trivial to implement by overriding the standard accessors and limiting the set of things that can be accessed externally. Since you have full access to the scope and stack, you can even limit things in a fashion similar to java's private/public/protected. I have used this many times to force attributes to be set only through a particular path that involves certain chunks of business logic.

    implement it in itself: Not sure what your point is, but you can certainly implement the Python VM in itself. The Python VM is actually quite portable as is demonstrated by the excellent Java based implementation found in Jython.

    strong typing: yes -- python has no strong typing, but it is trivial to check types and constrain APIs to particular types. At times, it would be nice to have strong types, but weak typing also has some extremely powerful uses and patterns.

    Too dog slow? Uh, no. See the Twisted project for an example of an "internet event server" whose web server implementation is faster-- and more flexible-- than apache. Not that apache is fast, mind you, but something that is faster than apache while maintaining flexibility can certainly claim to have better performance than the server used by, what, 50+% of the world's web servers?

    Python scales well, it is extremely reliable, and has excellent performance for an interpreted language. Python is used in many mission critical situations in both commercially saleable products as well as in embedded markets.

    Personally, I have built trading systems in Python. If you have ever been around a Trader when their technology doesn't work, you know that using technology that is fundamentally broken is exceedingly unpleasant (unless you enjoy being yelled at and having heavy things thrown at you). Python proved to be extremely reliable and allowed us to roll out new versions of the software very rapidly.

    Note that I am not a Python Zealot -- I program in some random combination of Python, C, Objective-C, Java and Lisp on a daily basis. Of all the languages, I prefer to use Python because I can get things done more quickly and with lower maintenance costs than any of the other languages. However, I'm not going to berate a client simply because they insist on using Java-- and certainly not if they have a good reason for doing so....

  24. python is not slow by Anonymous Coward · · Score: 0

    python is not slower than perl

    python can handle large apps like Zope easily. imagine something like zope in perl!

  25. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Anonymous Coward · · Score: 0

    I used to think Python documentation sucks. The truth is that it's not bad. It's just not for beginners, imho. Once you get into the language, the documentation somehow transforms into a useful, intuitive thing. Of course, it's probably a bad thing that newbies can't understand the docs that well, but as a rather experienced Python user now I find them very useful and not "unacceptable", "oddly-organized" or "indeciperable" at all. The language and the docs might be a bit weird at first, but once you take a few steps forward, you'll find you love (or possibly hate) them both.

  26. Until people start using PHP? by Surak · · Score: 2, Informative

    I'd have to say that more than a few people are using PHP. In fact, of the available Apache modules, guess which one is the most popular? (Hint: it's not PyApache or even mod_perl by a long shot)

  27. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Anonymous Coward · · Score: 0

    My history is similar, I learned VB with which I learned diddly about good code, but let me catch the bug, I learned Javascript which is a horrible language, but got me using C-style syntax and is fun to play around in (there are all kinds of stupid scripts you can do in javascript that you can't do in any other language), then I learned PHP, C and since then a few other languages. Choosing to learn PHP instead of Perl was a great decision because it's simple but powerful -- well fitted for what it's used for. Choosing to learn instead of Perl was an even better decision as I realized once I attempted to learn Perl.

    I swear, 90% of the Perl zealots have never used Python and 90% of the Python zealots have used Perl and dropped it.

  28. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Anonymous Coward · · Score: 1, Insightful

    I've never seen much point in the discussion "Perl or Python"? And unfortunally, most participants in the discussion know at least one of the languages not well enough to contribute something worthwhile. Many Pythoners don't come further than "too much punctuation", while many Perlers don't come further than "the mandatory white space". I don't know about others, but if all you can come up with against a language is "mandatory white space", I wouldn't program in any other language anymore.

    I don't have much against Python. It's a nice language. If I wouldn't already know Perl, I'd certainly code a lot in Python. Main reason I hardly code in Python is that it doesn't offer me much that Perl hasn't, and it just isn't worthwhile to become as fluent in Python as I'm currently in Perl. Two big plusses for Perl compared to Python: better error messages and warning (personally, I find Pythons errors cryptic and less suitable for beginners, although it by default gives a trace where Perl doesn't), and Perl has better documentation. Python 1.5.1 doesn't even come with any documentation by default; you have to install that separately. This is specially important since "core Python" is much smaller than "core Perl", even for simple things, you'd need to pull in a module. And unless you know your modules very well, you need to consult the documentation to find out which module to pull in. (Recently, I wanted to use sleep. It wasn't in os, or sys, or even in posix, but in timer (IIRC), which took me half an hour to find out.)

    Big wins for Python: a much, much cleaner OO system. While Perl took Python's OO system as a basis, in its implementation it took every wrong turn possible. Also, Python has less of "it is this way because it's the way of the C API" as Perl has. Python is probably easier to learn than Perl, certainly for people without a Unix background. For a coding project that consists of a group of relative novice programmers, from a varying background, I'd prefer to use Python than Perl. But then, because Python doesn't have something like use strict; (as mentioned by Chip), other options like Ada or Eiffel should be looked into as well.

    For individual programmers, I do not think the question "which is better Python or Perl?" is a reasonable question. To be a good coder in Perl, you need a specific mindset. Perl is a rich language, full of special cases and shortcuts. It's great for large groups of people. But that isn't good for an even larger group of people. Many people are much better of with a language that forces you to do things in a specific way, that has stricter rules on doing things. For those people, Python is much better. Frankly, I think that many of the people currently struggling with Perl are much better of coding in Python. The Python community should do more advocacy. (And of a different kind than "Perl sucks")

    -- Abigail

  29. Re:A (hopefully) unbiased opinion on Perl v. Pytho by frankie_guasch · · Score: 1

    the entire system needs to be scrutinized by security experts before any program written in Perl can be considered secure,

    #/usr/bin/perl -T

  30. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Anonymous Coward · · Score: 1, Informative

    Learn your terminiology:

    Python has STRONG DYNAMIC typing.

    C has WEAK STATIC typing.

    Perl5 has WEAK DYNAMIC typing (Argh!)

    Common Lisp has STRONG DYNAMIC and OPTIONAL STRONG STATIC typing.

  31. Re:Gentoo Zealot translator! (Mod this post) by soorma_bhopali · · Score: 0, Offtopic

    This is the damn good post. Mod this post up

  32. question on python's implementation by Maimun · · Score: 1

    Maybe I have to ask this in comp.lang.python,
    but anyway...
    The other day I gave python a try for the first
    time. I was a bit surprised by how the for loop
    is done. Rather than "for i from 1 to 600" that
    I expected, it is "for i in range(1,600)"
    That made wonder about how "range" is implemented.
    Is the whole range generated beforehand -- like
    is shell sctipting (when you do
    "for i in `seq 1 100000`", it generates the
    sequence first, and then i starts taking
    values from it); or it does it the smart way,
    generating the values one by one?
    Thanks!

    1. Re:question on python's implementation by thermostat42 · · Score: 4, Informative

      range generates the entire sequence beforehand. xrange, OTOH, will generate them one by one.
      HTH

      --
      no comment
  33. Re:A (hopefully) unbiased opinion on Perl v. Pytho by mbaranow · · Score: 4, Insightful

    My own opinion, like yours, is biased by the specific problem domain I applied Python to. For me that has been sys-admin scripts and network/cgi automation scripts.

    How is the ability to write a Python compiler in itself practially relevant to most users?

    Lack of strong typing and no support for data hiding can be thought of as a feature by those so inclined. This is just analogous to objections against 'whitespace sensitivity'.

    I more closely agree with one of the replies: that Python suffers from horrible documentation. I recommend looking at ActiveState Python for a slight improvement from the web manual.

    Some _personal_ highlights using python:

    - learning curve duration: 1.5 hours to start writing moderate complexity RE file parsing scripts.

    - ability to write a cgi enabled http server in approx 3 lines of code

    - ability to write a decent cross-platform opengl demo in approx 200 lines of code. using PyGame, PyOpenGL, Numeric etc.

    Also, please just ignore the zealots, don't acknowledge them with so much disclaimer.

    all the best,
    mbaranow

  34. Better review of the same book by Anonymous Coward · · Score: 2, Informative
    Cameron Laird: Book review: Python in a Nutshell "Cameron Laird reviews Alex Martelli's 'Python in a Nutshell' for UnixReview.com. Experienced, erudite author. Compelling topic. Proven format. What happens when you combine them? It depends. In book publishing, as with rock-and-roll bands and athletic teams, there are plenty of cases where apparent 'all-star' combinations have turned out badly. The fate of 'Python in a Nutshell' is happier, though. If you want to learn about Python, and can choose only one book to do so, take 'Python in a Nutshell'."

    Lifted whole cloth from Daily Python-URL

  35. Python's niche by vivek7006 · · Score: 2, Interesting

    Python is an excellent rapid prototyping language. Because of its neat syntax and simple philosophy, programmers can quickly create a working protoype in Python. Later, if needed, it can reimplemented in a faster programing language (like C++).

  36. Re:A (hopefully) unbiased opinion on Perl v. Pytho by bluFox · · Score: 1
    Have you tried doing any thing in perl or more possibly any other programming language other than python?

    From your comment i get the impression that you have not touched serious code in your life.

    How much hand holding do u need ?

    Or is it that you have some problem with reading english?

    The perl provides good documentation on how to use the features and libraries and has an efficient way of organising it. I dont have any thing against the python documentation or the language. It is different from other language and i like the difference. But that is not to say that other languages are full of shit.

    If you really want to compare things , please do us a favour and try using the things first.

    --
    ~561
  37. Re:A (hopefully) unbiased opinion on Perl v. Pytho by demi · · Score: 1

    I'm glad you found the online Python documentation helpful. However, you are mistaken if you think it's "certainly better than the free documentation on Perl." The online (that is, man page) documentation for Perl is very good indeed, and is highly practical even for nontrivial tasks. I learned Perl largely by printing out these man pages and reading them through. I've never encountered better free documentation except maybe for erlang.

    --
    demi
  38. Re:Python == Snake Oil by WetCat · · Score: 1

    Python == Snake Oil
    Python == Snake
    Snake Oil can be a Python Oil
    can be
    Python == Python Oil

    Oil == NULL!

  39. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Anonymous Coward · · Score: 0

    For those who didn't really "get" the previous comment - Python is a full OO language that (depending on the support on your platform) provides you with much the same capabilities as C++ et al. The same can certainly not be said of PHP.

    In this context, the advantages become clear.

  40. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Chmarr · · Score: 2

    I really don't see what the problem is. I learned Python TOTALLY from the documentation that is included with the Python package. I went through the tutorial to get the 'flavour' for the language, then browsed the library documentation to see what kinds of libraries there were, and the same with the language documentation. I go back to the library and language documentation when I need more information.

    It's, for the most part, fine.

    Yes, there ARE some holes here and there, as there are with a lot of the other types of documentation too. but it's hardly 'useless'.

    FYI, I used to be a avid Perl programmer until I had to reverse-engineer a Python program to modify it. (Xerox DocuShare)

  41. Re:A (hopefully) unbiased opinion on Perl v. Pytho by demi · · Score: 1
    Now Python on the other hand is almost completely a different story. It's supremely orthagonal and elegant in its design, with support for functions as first-class types, an enforcement of clean coding standards through whitespace sensitivity (most Perl coders object vehemently to this because it infringes on their ability to write really ugly code), etc.

    Sorry, but this is just baiting. My problem with a lack of block endings is that it makes it hard to see a complete or incomplete block when there is a large one--this is not a theoretical problem but one I've faced more than once, and is supremely frustrating.

    --
    demi
  42. Re:A (hopefully) unbiased opinion on Perl v. Pytho by tuffy · · Score: 1
    the entire system needs to be scrutinized by security experts before any program written in Perl can be considered secure,

    #/usr/bin/perl -T

    Ridiculous. Taint checking doesn't guarantee security any more than Java's sandbox does. Security is a process that requires an entire system (of which the Perl interpreter is just a part) to be scrutinized on a continuing basis; security is not a product, compiler flag or interpreter argument.

    --

    Ita erat quando hic adveni.

  43. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Brian+Quinlan · · Score: 1

    you can't implement it [Python] in itself

    Actually, there are people who are in the process of implementing Python in Python right now. The project is called "Minimal Python".

    it has no strong typing (even Perl's use strict is ridiculously better)

    Actually, Python is strongly typed.

    an OO system with no support for data hiding

    Most Python developers consider data hiding a misfeature. Unless you are operating in a secure environment or can enumerate every possible usage case for your code and prove that no one could ever need access to a private method, you should allow access. Just document the fact that the implementation could change in the future.

    If anyone is interested I'm willing to share my stories about being burned by C++ library developers who were too fond of data hiding :-)

    and it's too dog-slow to be used for real CS applications

    I'm not sure what "real CS applications are" but Python is frequently used for scientific computing.

    Cheers,
    Brian

  44. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Anonymous Coward · · Score: 0

    Not too bad for a (supposedly) first time /. troll... You've got potential.

    The entire system needs to be scrutinized by security experts before any program written in Perl can be considered secure.

    Says the C coder. *chuckle*

  45. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Brian+Quinlan · · Score: 1
    The biggest problem with Python, IMHO, is the online documentation.

    I partially disagree: I think that the library reference is excellent but that the language reference is terrible for beginners. I would suggest that you find a tutorial to learn the language and use the official documentation to learn the libraries.

    Take a look at:
    http://www.python.org/doc/Intros.html

    abandoning it quickly because the documentation (and installation process) were so opaque

    What part of the installation process is opaque?

    The Windows installer is a GUI installer that only asks you the install location.

    The UNIX install process uses the usual autoconf process. On Linux, for example, all you have to do is:
    % wget http://www.python.org/ftp/python/2.2.2/Python-2.2. 2.tgz

    % gunzip Python-2.2.2.tgz
    % tar -xf Python-2.2.2.tar
    % cd Python-2.2.2
    % ./configure
    % make install
    Cheers,
    Brian
  46. Re:A (hopefully) unbiased opinion on Perl v. Pytho by raju1kabir · · Score: 1
    The UNIX install process uses the usual autoconf process. On Linux, for example, all you have to do is:
    % wget http://www.python.org/ftp/python/2.2.2/Python-2.2. 2.tgz
    % gunzip Python-2.2.2.tgz
    % tar -xf Python-2.2.2.tar
    % cd Python-2.2.2
    % ./configure
    % make install

    Sounds delightful. My abortive experiences were back in Python 1.5 days, and I was unable to get it to run on Linux or FreeBSD. I had problems with missing libraries (both system libraries and internal Python libraries) and other random make errors. Finally I installed RedHat on a new machine and used the RPMs, which worked (though later failed to work on another machine that was not a fresh install).

    Installing v2 from RPM this time around was easy.

    --
    "Patriotism is your conviction that this country is superior to all other countries because you were born in it." -- GBS
  47. Score another niche for python by kpharmer · · Score: 1

    Too Slow? Depends on your application.

    I use it for ETL (Extract/Transform/Load) in data warehouse environments where millions of rows (and sometimes hundreds of millions) have to be transformed daily. These transformations range from simple text substitution to binary searches on large arrays. In this environment python performs adequately. More importantly however, it allows these applications to be developed quickly, tested quickly and maintained easily.

    Back in the day, these applications would have been written in C. Today a few are, or a few pieces of a larger python framework are, but given the cost of hardware it's simply cheaper to just buy a slightly larger box than spend another few weeks on development.

    I've used a wide variety of languages and vendor products for this activity, so far python has proven to be the best solution by far.

  48. you would have to be a little nuts... by Anonymous Coward · · Score: 0

    You would have to be nuts to use Python as your shell!

  49. Re:A (hopefully) unbiased opinion on Perl v. Pytho by hackstraw · · Score: 2

    I too don't think that Python's documentation is bad, in fact I actually think that its excellent. Much like the K&R C book. One thing that I admire about Pythons documentation, is that you could recreate the language from "Language Reference" section.

    I find that there are 2 (if not many more) kinds of documentation. Documentation that is meant to be read (more like a book), and documentation that is meant to be used (looked up while using like manpages and msdn). I believe that Python is that of the former, while PHP is that of the latter.

  50. It depends on the python version by Anonymous Coward · · Score: 2, Informative

    Conceptually, a for loop always iterates over the members of a sequence. range is just an example of generating a sequence. This is actually quite nice, because if you have a sequenence of lines in a file, you can do stuff like "for line in file:" and loop over them easily. You aren't stuck looping only over integers.

    As for your actual question: range does generate the entire list. xrange generates an object instead that calculates the items on the fly. Newer versions of python will be changing things (if they haven't already) so that range generates on the fly as well, and gets rid of the xrange object.

    Benchmarks have shown over time that xrange is not appreciably faster than range; you have to spend the time generating that number somewhere, either up front or one at a time. The only reason to use xrange is if you have a very large sequence to loop over, and can't afford the storage for the temporary list.

    1. Re:It depends on the python version by aleax · · Score: 1
      Loop performance does indeed depend on Python version. Python 2.3 (currently in alpha, nearing beta) comes with a timeit.py which lets you accurately measure the time taken by any snippet of code (guessing is bad, measuring is good), and also with an itertools module which adds important iterator based tools. On my old Athlon 1.2GHz Linux machine, I've measured:
      • for x in range(10000): pass
        1.45 milliseconds
      • for x in xrange(10000): pass
        1.07 milliseconds
      • for x in itertools.repeat(0,10000): pass
        0.87 milliseconds

      It's unlikely that taking a few hundred microseconds longer to loop ten thousand times will make a significant overall difference to your application's performance, but, if all you need is to "loop N times" (i.e., you don't need to access the loop index, just to repeat a given number of times), and if profiling your code has shown that this tiny optimization matters, then consider using itertools.repeat in preference to xrange, and xrange in preference to range. (Also consider upgrading to Python 2.3 ASAP -- it will offer you minor but nice speedups all over the place, and quite significant ones in some specific respects).
      --
      Alex
    2. Re:It depends on the python version by SharpFang · · Score: 1

      Would you please repeat the benchmarks on a low-memory system that is forced to use swap memory? Make the numbers 100 times bigger - Performance is one thing, allocating memory for a million integers is another...

      --
      45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
    3. Re:It depends on the python version by aleax · · Score: 1

      Unfortunately, I don't really have the freely available time to run measurements that may be of interests to others but are of no direct concern to me, particularly ones that are likely to require inordinate amounts of time and overload my half-gigabyte RAM system for quite a while.

      Fortunately, it is trivial to download and install the freely available, open source software I was using (Python 2.3a2), on any machine of your personal interest, and run the "benchmarks", which are really single, simple shell command lines after all. So, why don't you run those measurements, and let us know? Thanks!

      --
      Alex
    4. Re:It depends on the python version by SharpFang · · Score: 1

      Tested on 486dx80, 16MB RAM, mostly used by various demons. [root@wolf Kurs]# date ; python -c "for x in range(1000000): pass" ; date Sun Apr 20 23:43:17 CEST 2003 Sun Apr 20 23:45:05 CEST 2003 108s. [root@wolf Kurs]# date ; python -c "for x in xrange(1000000): pass" ; date Sun Apr 20 23:45:55 CEST 2003 Sun Apr 20 23:46:18 CEST 2003 23s. [root@wolf Kurs]# date;perl -e "for(\$i=0;\$i1000000;\$i++){}" ; date Sun Apr 20 23:49:04 CEST 2003 Sun Apr 20 23:49:19 CEST 2003 15s. :P

      --
      45 5F E1 04 22 CA 29 C4 93 3F 95 05 2B 79 2A B2
  51. Writing a language in itself by Da+VinMan · · Score: 2, Insightful

    It's a nerd thing (I would say it's a geek thing, but a geek is a nerd that can actually function well in society and I'm not convinced people who do these things have actually graduated to geek). If a language can be used to create an implementation of itself, and that implementation can in turn be run on itself, then it's considered proven that the language is sufficiently useful for "real" usage.

    I won't claim to understand it. It certainly doesn't do anything for the general populace. It ought to be enough to say that a language is Turing complete to say it can be used "for real". For some reason, it just gives the CS crowd big warm fuzzies when they do stuff like that.

    --
    Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
    1. Re:Writing a language in itself by tuffy · · Score: 1
      I won't claim to understand it. It certainly doesn't do anything for the general populace. It ought to be enough to say that a language is Turing complete [wikipedia.org] to say it can be used "for real". For some reason, it just gives the CS crowd big warm fuzzies when they do stuff like that.

      For compiled languages, implementing the language in itself serves a real purpose. For example, gcc is implemented in C which helps its portability. That is, the compiler can bootstrap itself into existence simply by compiling from an existing compiler on the system or cross-compiling itself from another system.

      For interpreted languages, however, implementing the language in itself is largely an academic exercise used to demonstrate language maturity.

      --

      Ita erat quando hic adveni.

    2. Re:Writing a language in itself by Da+VinMan · · Score: 2, Insightful

      For compiled languages, implementing the language in itself serves a real purpose. For example, gcc is implemented in C which helps its portability. That is, the compiler can bootstrap itself into existence simply by compiling from an existing compiler on the system or cross-compiling itself from another system.

      You're right. But I wasn't really addressing this. By implementing a "language in itself", I was really referring to more dynamic languages like Python, Perl, TCL, LISP, Smalltalk, etc. A Python program could run a Python interpreter, which could run a Python interpreter, etc. and it could change at run-time as per the user. Doing the same think in C, C++, Ada, Pascal, etc. doesn't even make sense unless you're talking about some sort of interpreted versions of those languages. I would say that bootstrapping is quite different from "dynamic re-entrancy" (my term, yeah it's not a real term).

      At any rate, either of these techniques are of little interest to non-nerds (see my above definition).

      Also, I wouldn't say that just because I can implement a language in itself, that the language is mature. Any Turing complete language can, theoretically, be implemented in any other Turing complete language. To me, a real developer who develops real solutions for real customers, a language is "mature" when I can use it for a client and not be let down by the language and the accompanying tools and environment. That's a far more difficult thing to measure and the measure is much more demanding to satisfy, once it is measured.

      --
      Please mod this post only if you think others should/n't read this. I have enough ego^H^H^Hkarma. Thanks!
    3. Re:Writing a language in itself by HiThere · · Score: 1

      Turing complete doesn't suffice. It's quite possible to have a Turing complete language that makes some things so difficult that no sane person will do them. And it's quite easy to design a Turing complete that is not only as specified above, but which has some features that are so difficult to implement in an efficient way that they are always implemented quite inefficiently...

      E.g.: You don't really need to implement much more than Boolean logic. Numbers can be made from vectors of booleans... etc. (I'm essentially just specifying a CPU in terms of software, though it would take a bit of effort to prove that it was really Turing complete.)
      And Turing complete says essentially nothing about IO. So you don't need to make that available. (Real useful, hunh?)

      --

      I think we've pushed this "anyone can grow up to be president" thing too far.
  52. Explain Python to me by Anonymous Coward · · Score: 2, Insightful
    Here's how I see the language.

    Combines the flexibility of syntax of C with the efficiency of Javascript. Python can't realistically support Lisp-style macros, doesn't support true closures, and many other things of Goodness that make Lisp languages so good for rapid coding. On the other hand, Python's dynamicism makes it very very slow. It's bad enough that the Python zealots apparently don't know how to program Java -- as minor corrections to their broken test code result in Java code that just stomps Python.

    So let's be honest here. Python is slow. So we have a slow language. So what? That's okay. I'm all for slow languages as long as they have features which make up for them. But Python's missing many of the goodies that make slow languages great. Macros. Closures. A good, scientifically-oriented numerical facility.

    I get this very strong feeling that Python has the worst features of both Lisp and C, while not having the best features of either of them. No wonder it appears, from my reading, that the vast majority of people pushing for Python are ex-Perl programmers. In other words, they're arguing for Python as a replacement scripting language for Perl. Not as a language for large-scale development or maintainability. But Perl is an easy target. It's a grotesque language, only popular because it was first to bat in the full-featured-scripting-language game.

    A malformed object oriented system. My other major beef with Python is that it has, to my mind, the single worst-conceived OOP system of any language I can think of at the moment.

    There are two basic families of OOP: class-based (C++/Java/CLOS/etc.) and prototype-based (JavaScript/Self/NewtonScript). The advantage of a class-based language is that you can equate classes with types, and the compiler knows exactly where a slot should be in an object, even an inherited slot. So they're fast. A great choice for a performance program on a desktop. The advantage of a prototype-based language is that it only keeps around the diffs: objects don't need to store tons of slots they don't use -- they just point to a superobject and say "go there for anything else". So they're highly memory efficient. Prototype languages are also highly dynamic, elegant, and small. A great choice for a scripting language, or a language for a PDA (like the Newton).

    Python is odd: it has both models. Underneath the model is prototype-based. Kludged on top of this is a class model. What the heck? Do not think this is a good thing. Each model has made sacrifices from the ideal -- by using both models, you're making all the sacrifices at the same time. It appears to me that Python has managed to achieve the worst of both features: it's not as dynamic or small and elegant as a prototype OOP language, and it's not nearly as fast as a class-based OOP language. It has no advantages over a prototype-based model at all. In reality, the kludge means that Python programmers have to keep more syntax rules in their brains in order to achieve less than a prototype language would provide.

    I get the feeling that what happened was Python started as a procedural Perl-style language, then hacked on a prototype model, then due to, I dunno, misinformed "customer complaints", hacked on another class-based model on top of that. What a mess.

    Anyway, this is how I see the current state of the Python world. Why do people use this language? My guess is that it's because they're ex-Perl programmers, and made an incremental jump to the next slightly better language.

    1. Re:Explain Python to me by escalation746 · · Score: 2, Insightful

      > Python can't realistically support Lisp-style macros, doesn't support true closures, and many
      > other things of Goodness that make Lisp languages so good for rapid coding.

      Strange that Python doesn't support Fortran type line numbers or BASIC type OPEN statements either. If you want to use Lisp, use Lisp. Python is its own animal.

      > Python is slow. So we have a slow language. So what?

      Exactly. So what. The speed of the interpreter is usually not the bottle-neck in most app domains. If it is, use a different language. Python is fast enough for most uses, and can easily bind to libraries in C or what-have-you for those parts of your app that need performance.

      In the meantime, you can develop your program faster and more error-free, by a factor of 5x or 10x depending on which study you believe. Getting a project done, on time, on budget, and working correctly is more impotant than speed almost always.

      > A malformed object oriented system.

      I am not a purist. I like to get work done, and have other people understand what I am doing and why. Python has a highly usable object-oriented architecture that works very easily for 99% of what I need, and can be hacked (thanks to its marvellous introspection) for the other 1%.

      Python is easy to learn, easy to write, easy to read, and produces bug-free code faster than any language I have ever used. The number of rules I have to keep in my head is approaching zero.

      Really, your comments demonstrate that either a) you have never programmed a real-world project in Python, or b) you are too attached to Lisp to give Python a fair shot.

      Either way, you apparently care more for theoretical concerns than practical, and so are not a good candidate for Python anyway.

      robin

      --
      A rich couple found their ideal pet in a dog that makes e-mail programs.
    2. Re:Explain Python to me by Anonymous Coward · · Score: 0

      Sure, Python isn't a speed devil, but it's fast tnough for most purposes. Also its memory footprint is at least better than common Java VMs. :)

      Python doesn't have macros. Talking about macros identifies you quite reliably as a Lisp programmer with a grudge as all that popularity should go to lisp, dammit! Python has a syntax which allows for a clear expression and recognition of common idioms than Lisp though.

      Python has had statically nested scopes for a while, which means (somewhat limited) closures:

      PEP 227

      You can also use objects to simulate them. I've used objects to simular higher order functions as well quite nicely.

      I don't think the vast majority of Python programmers are ex-perl programmers. I don't have statistical evidence for this assertion, but I think the burden of evidence here is on you anyway.

      Python does have numeric and numarray for scientific numerics, and more. numeric has been around for years so I wonder how you missed that. Oh, it wouldn't be 'good', of course. :)

      As to the object system I can't really comment a lot, I can just say that I don't find myself limited by it at all. There are also quite a few metaclass based systems out there that demonstrate its flexibility. You haven't shown how Python's design limits developers and how it does the worst of both worlds.

      Sure, Python isn't the fastest, but we already agreed on that. It's just fast enough for a large quantity of purposes.

      So, to me Python is a nice language with just enough syntax, but not too much. It allows clear idioms with its built-in higher level datastructures, while allowing a lot of flexibility if you need it as well. Its standard library comes with a lot of useful things.

      Python also interfaces with C, C++ and Java systems nicely, and is designed to work with the environment instead of endlessly layering on top of the underlying systems, which makes the language more heavy weight and harder to integrate.

      Python is orthogonal where it counts, but also pragmatic where that counts. It's not particularly appealing theoretically, but it just works well in practice.

      Python has a vibrant community of users as well,
      an asset that shouldn't be underestimated.

      Python is a powerful language that does lots of things well in an easy to understand way. It doesn't excell in any department and isn't pure, but it's very well balanced overall and that's why it can be a joy to work with.

    3. Re:Explain Python to me by FatherBusa · · Score: 1

      I am not a purist. I like to get work done, and have other people understand what I am doing and why. Python has a highly usable object-oriented architecture that works very easily for 99% of what I need, and can be hacked (thanks to its marvellous introspection) for the other 1%.

      and then the inevitable . . .

      Either way, you apparently care more for theoretical concerns than practical

      Please. If liking clean, well-encapsulated OO (without that absurd "self" business) makes you an impractical theorist . . . But of course, it doesn't. It makes the defenders of such misprisions sound like morons ("Don't know why you need that thar satelite -- my donkey works just fine!)

      We all like to "get work done," and Python has a lot going for it in that department, but it is preposterous to argue that Python's OO system advances the cause of "getting work done" if you're serious about OO. People who think so are hardly impractical theorists. They might easily turn around and assume that you have never tried to design a serious object-based system in Python.

    4. Re:Explain Python to me by Anonymous Coward · · Score: 0

      Because it's easy to learn and easy to master, sir Master Lisp Hacker.

    5. Re:Explain Python to me by Brian+Quinlan · · Score: 2, Insightful

      But Python's missing many of the goodies that make slow languages great. Macros.

      Not having macros was a deliberate design decision. One of Python's key stengths is easy readability and adding the ability to add/modify language contructs might compromise this.

      A good, scientifically-oriented numerical facility.

      What facilities are you looking for, in particular? Python has a double-precision floating point type, unbounded integers and complex numbers as part of the core language. Are you looking for something else, like rationals?

      Or is it libraries that you are looking for? If so, here are the docs for
      Numeric

      Python is odd: it has both models. Underneath the model is prototype-based. Kludged on top of this is a class model. What the heck?

      I don't understand your complaint. Can you discuss it in terms of semantics e.g. I would expect method to get resolved like this but they get resolved like that....

      I get the feeling that what happened was Python started as a procedural Perl-style language, then hacked on a prototype model, then due to, I dunno, misinformed "customer complaints", hacked on another class-based model on top of that. What a mess.

      Python is fundamentally object-oriented. Even integers are treated as objects.

      Cheers,
      Brian

    6. Re:Explain Python to me by Anonymous Coward · · Score: 0
      It's true, I code some Lisp. I am, however, primarily a Java and C++ programmer.

      Python's closure handling is broken; it can't even handle simple nested lexical scoping. This can be quite a big deal for writing fast, on-the-fly code. More damning, Python doesn't have much company here: all other related languages that I can think of have no problem with the closure handling. Java^H^H^H^HECMAscript. Newtonscript. Scheme. Ruby. Mathematica. Heck, even Java can do multiple closure nesting in anonymous classes. [BTW, Java has another closure boo-boo -- local outer variables must be final -- but that can be worked around with a simple size-1 array]. As to numerics, sure, I've heard of Numarray etc. But function packages do not language elements make. By scientific numerical data types I was referring to stuff like Mathematica or Scheme, which have real data types in the forms of rationals, fractions, complex numbers, with supertypes etc., as opposed to a scheme built around the data types provided by a typical processor (float, double, etc.). The kind of goodness you get in return for slowitude.

      As to the object system: my general feeling, and I think the feeling of most people who've used both class-based and proto-based models, is that proto-based models are much more flexible and intuitive. You need a good reason to use a class-based model. Typically the reasons are either (1) speed or (2) compile-time bug-checking via strong typing. Both are good reasons.

      Problem is: Python has this class-based system hacked on, but neither of those justifications is valid, because the proto system is still there. Net result, all you have is lots more syntax to keep in your brain at one time, but really can't do anything more elegantly or simply than if you had just had the proto system in the first place. The only reason I can think of for even having the kludged-on class gunk is because users complained that they couldn't grok the proto system. Kowtowing to users rather than making them learn a new concept is fine -- but heck, Python is requiring users to keep track of indentation!!! Kowtowing isn't its style.

    7. Re:Explain Python to me by Peaker · · Score: 1

      Please explain how "self" is absurd? I'm assuming you refer to the explicit method argument. In actuality, I have witnessed at least one case where the explicit naming of the given instance let me define classes nested in methods, allowing the internal methods to access the namespace of the external class's methods (achieving the more important lexical access goals of closures, btw).

      Supporting real closures that allow messing of the enclosing function's namespace with new references is a problem because it clashes with the concept of unstated local variables. There are many syntatic-level ways around it. For example, assuming full closure support:

      def func():
      def internal_func():
      a = 5
      internal_func()
      return a

      Can be implemented instead via:

      def func():
      a = [None]
      def internal_func():
      a[0] = 5
      internal_func()
      return a[0]

      Note the closure above does not make it possible for nested functions to have local variables of their own.

      As for the Object Model in Python - its very clear to me, and seems quite simple too. Python has slots for functionalities - because its a great way to express the idea of "standard methods" such as construction, addition, and other basic concepts. This is very easy to understand and follow in code.

      class C:
      def __init__(self):
      print 'This initializes', self, 'and is quite clear about it!'

      Subclasses work by pointing at their superclass to find the method implementations - but this is completely unrelated to the slots. I understand that technically, on the low implementational level, there is a link between the way a method is looked up (in a slot, or by name), and the way subclassing works (overriding functions in slots, or pointing to super class). Conceptually, however, I don't understand why anyone has to keep this information in mind.

      When programming Python, one does not think of slots and pointers to superclasses. Instead, one thinks of __init__ as a standard name for constructors, of __add__ as a standard name for the '+' method, etc. All lookups are conceptually by name, and superclass method finding rules are well established and documented - as a completely different concept.

      I'd be happy if you could reiterate why you thought the low-level method lookup mechanism mattered to the programmer or the language, and would appriciate examples in code.

    8. Re:Explain Python to me by leed_25 · · Score: 1

      ,----
      | A malformed object oriented system. My other major beef
      | with Python is that it has, to my mind, the single
      | worst-conceived OOP system of any language I can think
      | of at the moment.
      `----

      You obviously have not tried the one in PHP.

    9. Re:Explain Python to me by Peaker · · Score: 1

      which have real data types in the forms of rationals, fractions, complex numbers, with supertypes etc.,

      rationals are soon to be added to Python, and can for now be implemented in the form of two arbitrarily long objects. fractions are doubles. complex numbers exist in Python even in the syntatic level (try evaluating "4+6j", or "1j**2").

      What do you mean by supertypes here?

      Python's closure handling is broken; it can't even handle simple nested lexical scoping. This can be quite a big deal for writing fast, on-the-fly code

      What version of Python have you tried? Python has fixed this problem since Python 2.1. Lexical scoping works fine in Python, except for the fact local variables are local to the innermost function declaring them, so that assignments into outer scopes is not allowed. Assignment into attributes of objects from outer scopes is easily possible though, resolving the requirement to access the outer scope.

      As far as I know, Java has no closures or lexical scoping at all.. Can you show an example Java code with lexical scoping?

      As to the object system: my general feeling, and I think the feeling of most people who've used both class-based and proto-based models, is that proto-based models are much more flexible and intuitive. You need a good reason to use a class-based model. Typically the reasons are either (1) speed or (2) compile-time bug-checking via strong typing. Both are good reasons.

      Python is not a class-based system. The 'slots' are merely an implementation-level detail that does not interest the Python programmers, and seen as a 'standard name' for common operations.

      What extra syntax are you talking about?

      Python syntax is the smallest of all the languages you mentioned, if you include standard macros and special forms in the Lisp variants' syntaxes.

      Again, I'd like to understand where you think Python has a class-based type system. With an example, if you can.

    10. Re:Explain Python to me by smallpaul · · Score: 1

      Python's closure handling is broken; it can't even handle simple nested lexical scoping. This can be quite a big deal for writing fast, on-the-fly code. More damning, Python doesn't have much company here: all other related languages that I can think of have no problem with the closure handling. Java^H^H^H^HECMAscript. Newtonscript. Scheme. Ruby. Mathematica. Heck, even Java can do multiple closure nesting in anonymous classes. [BTW, Java has another closure boo-boo -- local outer variables must be final -- but that can be worked around with a simple size-1 array].

      Python has closures with roughly the same restriction as Java's. So what's your problem?

    11. Re:Explain Python to me by vague · · Score: 1

      Thing is, the class/prototype distinction has yet another use, one that is wholly pragmatic but not theoretically significant. It's documentation. Having a few orthagonal concepts as the basis for a language is a good thing that has many disadvantages. Actually programming in these concepts might not be a good idea. Python _is_ a particular set of abstractions, chosen with a particular goal in mind, to support each other and a particular style of coding. It could have had more of a theoretical basis, but it works anyway.

      Python has disadvantages, and it does not have the power or flexibility of many other languages. But it does have a sound underlying philosophy and it does a good job of expressing it in the language design. Theoretical soundness and beauty factored in rather late in the design process, and in hindsight a bit of foresight (and more research) might have prevented some of the theoretical ugliness that rears it's head in the current design. Python is now (slowly) being retrofitted to fix these historical problems, at least to some degree.

      That you don't see the value in Pythons original design philosophy is another matter that can't be fixed. I do, and I like it a lot, even though my own language would have a sounds type system.

      --

      -
      Listen. Strange women lying in ponds distributing swords is no basis for a system of government.

    12. Re:Explain Python to me by vague · · Score: 1

      "Having a few orthagonal concepts as the basis for a language is a good thing that has many disadvantages."

      =

      Having a few orthagonal concepts as the basis for a language is a good thing that has many _advantages_.

      --

      -
      Listen. Strange women lying in ponds distributing swords is no basis for a system of government.

    13. Re:Explain Python to me by Anonymous Coward · · Score: 0

      Java's lexical closures are properly nestable. Python's are not. That's a BIG difference!

    14. Re:Explain Python to me by Anonymous Coward · · Score: 0

      Python's basic OO style promotes class notions: the inheritance tree is set up so that nonleaf nodes are classes and leaf nodes are instances.

      class Super: # make a class
      .....
      class Sub(Super): # make a subclass
      .....
      x = Sub() # make an instance

      But in fact, this is all fiction down deep: there is no necessary distinction between instances and classes. Nonetheless, one must ask WHY Python has a class declaration at all. Point being: you can treat Python stuff like protos, or you can treat them like classes and instances. And you have language features for both. Which means that if you interoperate with other programmers, you have to be conversant in BOTH. Even though the class mechanism doesn't buy you anything.

      Compare this to Newtonscript, which is an elegant, simple, pure-proto system:

      super := { ... };
      sub := { _proto: super, ... };
      local x := { _proto: sub };

      That's pretty much all there is to it. Here there is no distinction between classes and instances at all. Because you don't need one. sub is a kind of super. x is a kind of sub. This is how Python actually implements things (and like Python, it's slow). But unlike Python, we don't put class cruft on top for no particular reason (that I can see).

      As to Java with lexical scoping, here ya go:

      void foo() {
      final int x = 9;
      return new Bar() {
      public void baz() {
      return new Quux() {
      public void quuux() {
      return x;
      }
      }
      }
      }

      Now, it's true that x has to be final. That's a stupidity in the Java language definition, which needs to get overcome in the future. But this can be trivially gotten around by making x a final array of size 1, and then you can change x to your heart's content, just like any Lisp closure.

      To my knowledge, Python cannot do nested closures like this.

    15. Re:Explain Python to me by Peaker · · Score: 1
      Python's basic OO style promotes class notions: the inheritance tree is set up so that nonleaf nodes are classes and leaf nodes are instances.

      You're assuming that instances are 'inheriting' from the classes they're instantiated of.

      But in fact, this is all fiction down deep: there is no necessary distinction between instances and classes. Nonetheless, one must ask WHY Python has a class declaration at all.

      The differentiation between instances and classes is taken from Smalltalk, and done for several reasons:

      Instances are instantiated, subclasses are defined. Instantiations run a class's constructor, while definitions are almost a simple assignment (metaclass functionality aside).

      Class methods are unbound, while instance methods are bound. Differentiating classes from instances allows one to refer to a class's method in general, or to one bound (curried) to a specific instance in a syntax-friendly way. (MyClass.method)(my_instance, a, b, c) is similar to (my_instance.method)(a, b, c).

      Subclasses are conceptually different from instances. The syntatic differentiation allows easy clarification of which concept the code is trying to express. Whether a type of instances is being declared, or a single instance.

      Subclasses can be of multiple classes. Instances are always of one class.

      This is how Python actually implements things (and like Python, it's slow).

      For the implementation of class member descriptors, and due to the binding I mentioned above, Python classes are implemented a little differently. The instance has a __class__ attribute, pointing to the class, the class has a __bases__ attribute for a list of its base classes.

      Also note that Python, since version 2.2 is moving to real class systems, that really use fast slot lookups in exchange for some of the flexibility allowed by the previous proto design. Little change in interface is noticed, except for more consistent unification of the type and class of instances (classes are now first-class types), the inability to change the class of instances, and the inability to multiply inherit under some conditions.

      To my knowledge, Python cannot do nested closures like this.

      Untrue. Python, ever since version 2.1, can easily do such things:

      I'd like to ask whether the Java code you pasted is actually correct, because the return types of some of these functions are void, while they return ints or functions/classes.
      I'd like to see Java code that compiles, or a better explanation of what the 'void' means in those method declarations.

      def f1(x):
      def f2(y):
      def f3(z):
      return x,y,z
      return f3
      return f2

      Or alternatively:
      f1 = lambda x: lambda y: lambda z: (x, y, z)

      There is a similar problem to Java's:

      def f(x):
      a = [None]
      def g(y):
      x = y # This will create a local 'x' in g
      a[0] = y # This will assign to a of the outer scope

      Also things like:
      def f(x):
      class A:
      def __init__(self, y):
      self.x, self.y = x,y
      Are allowed (including any number of nested functions or classes, ofcourse).

      You must have tried Python before 2.1, or Python 2.1 without enabling lexical scoping ("from __future__ import nested_scopes").

    16. Re:Explain Python to me by Anonymous Coward · · Score: 0
      Oops, there were typos in my Java code. Shouldn't have been void, should have been proper return values. Sorry about that. Anyway, change the return values to their correct form, and it compiles fine. As to Python's nested lexical scopes, you're right, it appears that Python does indeed do multiple nesting, though with the same bug that bites Java (final variables). But...
      The differentiation between instances and classes is taken from Smalltalk, and done for several reasons:

      What is surprising to me, and a little disturbing, is that none of these reasons is justified. (1) there is no reason why construction has to be per-instance rather than per-class [in python-speak, or in most other similar languages, 'per-proto] (2) There is no reason why class methods need be unbound -- and in fact this appears to limit the functionality of the language. (3) The only conceptual difference between classes and instances is fictional. (4) multiple inheritance is trivially handled in prototype languages.

      I get the feeling you've not used a true proto language much. Which is understandable! There aren't many. Javascript, Newtonscript, and Self are probably the three biggest ones. However, it honestly is true that none of the reasons provided is actually a reason.

      The primary reason for using a class-based language is that it is typed. Classes define types of which instances partake. Typing is often a good thing. First off, it allows the compiler to make the system to do many more compile-time checks, eliminating errors and removing the necessity for various run-time checks, speeding the program. Second, it enforces an order which (supposedly) makes the program more structured, maintainable, and grokkable. It appeals to the software engineer in us.

      The secondary reason for using a class-based language is that instances contain all of the slots defined by their classes (except for class-shared ones). At any rate, it is clear exactly where a slot is located, in a typical class-based language, and so the compiler can avoid hunting up the inheritance chain proto-style and instead just grab the slot in an O(1) fashion. Thus class-based languages are fast. The expense of class-based languages are three: (1) they are syntactically more complex compared to proto languages. (2) They come at the expense of memory utilization (instances must contain slots they never use or change). (3) They are not as dynamic as proto-languages, which can change parents, or whole class definitions, arbitrarily.

      Because Python is (1) typeless and (2) proto-based underneath, It can't take advantage of either of these reasons. Thus we have class-based cruft which adds syntactic complexity, while conferring neither of the primary advantages that class-based languages afford.

    17. Re:Explain Python to me by Peaker · · Score: 1

      You have ignored the unification of types and classes I mentioned - that does indeed use slots for all standard-named methods (the vast majority of method calls).

      Therefore Python enjoys the order that appeals to the software engineer, and the speedup due to slot lookups.

      Proto-based unification of classes and instances, by call constructors on classes and such seems to be an 'artificial' and non-natural unification of two similar but different concepts.

  53. Dive Into Python by L3WKW4RM · · Score: 1, Redundant

    I've got to recommend Dive Into Python as a great, free, online Python book.

    (PS. I own the dead-tree version of Python in a Nutshell, I think the above is nice to use as a while-programminng guide)

  54. Re:A (hopefully) unbiased opinion on Perl v. Pytho by john_roth · · Score: 1

    This comment will probably make it obvious, but I'm not a programmer (not by profession at least). Anyway, here's my question: Why would someone want to implement Python in itself?

    That's a good question! There are two answers besides the technical flourish. One is that it demonstrates that the language is able to handle system level tasks (as opposed to, for example, RPG.)

    The other is that being able to write the interpreter in Python vastly simplifies the task of evolving the language. You not only have a reasonably straightforward Python to C translator for the production interpretor, but you can also run the interpreter under itself for testing and debugging. See Squeak for another example where this has a real payoff.

    John Roth

  55. Alternative Recommendations by Paul+Komarek · · Score: 2, Informative

    I cannot agree with the reviewer that M. Lutz's O'Reilly "Python" book is good. I disliked this book nearly all the way through. It jumped around too much, used too many words, and had insufficient detail on more advanced topics. Given that the book is about three inches thick (from memory -- I gave away my copy), there's enough room for details on everything.

    I concur with other posters that the "Essential Reference" (white and red from New Riders, written by D. Beazley who did SWIG) is an awesome book. It is concise, making it a good reference. I wouldn't think it was a good book for those who have never programmed. If you have some programming experience, though, I expect you'll appreciate this book.

    The "Quick Python" book from Manning is nice, too. This was my wife's preferred book for learning Python. I've looked through it a bit, and it seems decently concise but with more explanation than "Essential Reference". I used its section on extending Python through C, and found it very useful. That section didn't have everything bit of reference that I needed for conversion specifiers, but their examples were dead-on what I needed to get started.

    I recently finished reading through "How to Think Like a Computer Scientist: Learning With Python" from Green Tea Press. This book is not a complete reference or guide for Python, nor will it be particularly 'useful' for people who have taken university-level programming and data structures classes. However, it seems to be an AWESOME book for people who don't yet program, or whose only experience is web programming or VB or Perl programming (I'm not saying those things are bad, but very often they don't encourage reasonable programming discipline and methodology). I write "it seems" only because I'm not a beginner or an instructor for intro to programming courses.

    This book ("How to Think...") is aimed at classroom use, so it doesn't include info about installing Python or starting the Python interpreter under Windows, etc. It does preach solid computer science. Parts of their approach seemed a bit unusual to me, compared to my more classical training, but after a few gripes I always was forced to conclude that their approach was valid and as concise and clear as it could be. The authors are aware of the book being used in high schools and community colleges. I expect that mature students, or any adult intrested in learning proper programming, would benefit from starting with this book.

    -Paul Komarek

    1. Re:Alternative Recommendations by bzhou · · Score: 1

      You're probably confusing Learning Python with Programming Python. Both have M. Lutz as author. IMHO, "Learning Python" is a pretty good first book on Python.

    2. Re:Alternative Recommendations by Fourier · · Score: 2, Informative

      I cannot agree with the reviewer that M. Lutz's O'Reilly "Python" book is good. I disliked this book nearly all the way through. It jumped around too much, used too many words, and had insufficient detail on more advanced topics. Given that the book is about three inches thick (from memory -- I gave away my copy), there's enough room for details on everything.


      Mark Lutz actually has two noteworthy Python books, "Programming Python" and "Learning Python."
      "Programming Python" would be the thick book you refer to; the author of the review recommends "Learning Python," a thin book for those just learning the language (or maybe still learning programming). It has been pretty well received.

    3. Re:Alternative Recommendations by Paul+Komarek · · Score: 1

      Actually, I had both. Thanks for the clarification, since I screwed up the title. "Programming Python" is indeed the book I was referring to by Lutz. I remember little about "Learning Python", and didn't want to say anything about it. It was my first Python book, and I guess I learned a fair bit from it. Hard to say at this point.

      -Paul

  56. Re:A (hopefully) unbiased opinion on Perl v. Pytho by sketerpot · · Score: 2
    For python, I think that the tutorial was meant to be read (and, if you forget all that dictionaries and tuples can do, to be referred to), and the library reference is pretty good for quick reference.

    I just don't see the problem.

  57. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Anonymous Coward · · Score: 0

    The perl provides good documentation and the python provides good documentation too.

    *yawn*

  58. Porting Python to C is non-trivial by tungwaiyip · · Score: 1

    In sounds like common sense, if you want performance, port it to C, C++, etc. In practice, you may as well port it to assembly language to gain some performance.

    Python has many high level data types such as tuple, list and dictionary as well as operators to make them useful. These datatype prove to be useful for a lot of programming tasks. This is why programmers find it so productive with Python. A simple pythonic operation such as getting an indexed item from a dictionary would be translated into many many lines of C code. Perhaps hundreds of lines if you want an efficient implementation. It just wouldn't be the same program if you rewrite it in C.

    Nothing against rewriting code in different language. I just want to point out that one is lot more high level then the other. For me Python is a good choice for tasks where programmer's time is more important than CPU time.

    1. Re:Porting Python to C is non-trivial by black+mariah · · Score: 1

      And that's where the good stuff comes in. Python can easily be called from C programs to handle things that would be tricky to implement in C (such as dictionaries and lists). Take all the low level stuff and redo it in C, then leave the higher level stuff for Python. Best of both worlds, and probably with a major speed increase.

      --
      'Standards' in computing only impress those who are impressed by things like 'standards'.
  59. Tabs by mrfiddlehead · · Score: 1
    I tried to like Python a couple of years ago. I bought a book and plowed through it and wrote a few scripts, but I could never get used to looking at the damn blocks of code indented by whitespace. I guess this is one of the most common beefs. I sure wish they'd optionally support braces to delineate blocks of text.

    Ruby looks quite nice, but I haven't tried it yet.

    --
    :wq
    1. Re:Tabs by Peaker · · Score: 1

      Just curious, Do you write your code unindented, in other programming languages?

    2. Re:Tabs by JamesOfTheDesert · · Score: 1
      Ruby looks quite nice, but I haven't tried it yet.

      Make a point of trying it out; you won't be sorry. http://www.ruby-lang.org

      --

      Java is the blue pill
      Choose the red pill
  60. Re:A (hopefully) unbiased opinion on Perl v. Pytho by foote · · Score: 2, Interesting

    That being said, Perl is at least useful for many things ("practical," I believe it's called).

    Python is useful for many things as well, as evidenced by the number of people who use it, including Boeing, Disney, Hewlett-Packard, Industrial Light & Magic, Intel, JPL, Lawrence Livermore Labs, NASA, and Yahoo. Programmers at places like these are usually allowed to make their own decsions about their tools, and they chose Python. These guys are good. They don't use tools that they don't like. This is not to say that Python is their only scripting language. I know NASA makes good use of TCL, and probably uses Perl as well.

    Peter Norvig says "Python has been an important part of Google since the beginning, and remains so as the system grows and evolves. Today dozens of Google engineers use Python, and we're looking for more people with skills in this language." Norvig is director of search quality at Google. Look at his home page (www.norvig.com/. When a guy who writes AI books talks up a language, it means something. I'm not saying it means everything. It's another piece of data to put on the scales.

    More details on use of Python:
    www.python-in-business.org/success/
    http://www.python.org/Quotes.html

    Finally, I note that the Google jobs page mentions Perl 11 times and Python 15 times, for what it's worth. I didn't read the job descriptions.

  61. Re:A (hopefully) unbiased opinion on Perl v. Pytho by tandr · · Score: 1

    Just out of curiosity, do you have some link to this "trading system" of yours?

    Thanks.

  62. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Sleepy · · Score: 1

    > Overall, as a learner I found Perl's documentation to be the best, and as an advanced developer I find PHP's to be supreme, bar none. Python's is a disgrace, useful to neither beginning nor advanced users.

    Yep, I've come to those exact same conclusions. Take a look at the "win32*" API docs hosted at ActiveState, for example win32net.DriveAdd()

    The docs basically say "Wrapper for the win32 call -- see MSDN for details".

    No examples of usage? Thanks! OK, I go to MSDN and see a C data struct for arguments. I'm not a total moron so I deduce the gist of it, but I spend 30 minutes in the debugger (going mad).

    The problem?

    One of the dictionary keys this Python wrapper expects is password. Fine. But someone decided the wrapper should call it "passwd" -- not "password", like the MSDN documentation indicates.

    If you pass in data['password'], the wrapper will accept this, use a NULL password, and not raise an exception. WTF?

    The docs are not only incomplete and a little too terse, but they can be *wrong*. That blows.

    I bought "Python Programming with Win32", but it glosses over the wrappers. A lot of trial and error is needed.

    I *still* prefer Python over Perl for a general-use language. Python may have a fanatical enforcement of whitespace and coding style, but that's fantastic for reading someone else's code. Perl has lots of unintentionally obfuscated code.

    Python's biggest weakness is it's a learning language, which in itself is fine... but no one seems to push the boundries. It could be a great language for application prototyping/automation/etc, if we hadbetter documentation for modules. End rant. :-)

  63. Extending Python with C by frehe · · Score: 2, Informative

    If you need more speed than native Python provides, you can always write code in C and wrap it so it is callable from Python. The wrapping is really easy to do, once you have understood the general concepts involved in it. The product I currently work on has about 10000 lines of C code (crypto and networking) which is used this way, and it works perfectly. For more information about extending Python with C, see:

    Extending and Embedding the Python Interpreter

    Python/C API Reference Manual

  64. learning python good for programming nubies? by the_2nd_coming · · Score: 1

    try again.

    how about:

    learning to program using python

    a much better book for first, learning to program and second, learning the basics of python.

    THEN moving to learning python.

    --



    I am the Alpha and the Omega-3
  65. Essential Reference / New Riders by Petronius · · Score: 1

    Great book. I have read several of the OReilly titles. They are great to understand how historically some features got into the language, etc. They also greatly contributed to the Python advocacy. But in a way, it's also their downfall: they tend to be dated.
    The only Python book I read now is the New Riders title. I can find just about anything in it as fast as I can search Google. OK, *almost* as fast.

    --
    there's no place like ~
  66. Re:A (hopefully) unbiased opinion on Perl v. Pytho by bzhou · · Score: 1
    Isn't it a bit off topic to compare Perl and Python under a Python book review topic?

    Now, with that in mind, and being a Python user for years, I do have something to say about the shortcoming of Python's design:

    I think it's important to get stackless to merge with the main Python. Some Python developers argue continuation does not bring enough benefit. I think it's shortsighted - for web development, Squeak Smalltalk have Seaside, Cocoon uses Rhino/continuation, all use first class continuation as the next generation web development model. The advantage will soon show. BTW, "continuation" solves the multi-level break problem easily, exception, generator, lightweight thread can all be implemented on top of it.

  67. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Anonymous Coward · · Score: 0

    Use Ruby - the best of both worlds, fully OOP (on a par with SmallTalk) with regexp/string handling of Perl.

  68. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Brian+Quinlan · · Score: 1

    Python 1.5.1 doesn't even come with any documentation by default; you have to install that separately

    You are basing your experience on a Python release that is over five years old!

    Cheers,
    Brian

  69. Syntactically Significant Whitespace - YUCK!!! by fanatic · · Score: 1

    I have never gotten around this. I probably never will get around this.

    With braces, as in perl or C, I can bounce on the % key and find the ends of a block unequivocally. I can cut and paste from one editor to another, and it still works. I can change tabstops and everything still works.

    --
    "that's not encryption - it's a new perl script that I'm working on..." - from some Matrix parody
    1. Re:Syntactically Significant Whitespace - YUCK!!! by Peaker · · Score: 1

      The % feature depends on your editor. If your editor is decent, you can jump up/down Python blocks as well, or at least script the editor to be able to.
      As for tabstops - that's indeed a problem with Python, one a Python programmer should be aware of.
      However, once the Python programmer is aware of this problem, its not really serious, because rarely will indentation problems result in anything other than IndentationError raised, and you can simply search-replace all tabs to 4 or 8 spaces, or vice versa.

      The other side of the coin is that all Python code everywhere and from anyone is properly indented making it more readable. The language syntax becomes less noisy, and less redundant (expressing blocking via symbols _and_ indentation), reducing the odds of having code that looks differently from what its really saying.

  70. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Brian+Quinlan · · Score: 1

    >Overall, as a learner I found Perl's documentation to be the best, and as an advanced developer I find PHP's to be supreme, bar none. Python's is a disgrace, useful to neither beginning nor advanced users.

    Yep, I've come to those exact same conclusions. Take a look at the "win32*" API docs hosted at ActiveState, for example win32net.DriveAdd()


    I tried to find win32 bindings for Perl and couldn't. Could someone point them out to me please? I did notice that the only Perl COM solution seems to involve paying money. The Python solution is free.

    Which might be why the Python win32 documentation isn't very strong: it is not done by the core Python team, nor by a company that charges you money, but by one really smart guy (Mark Hammond) who, in addition to doing work that pays the bills, develops and documents the Python win32 bindings pretty much by himself.

    I think that the core Python library reference is excellent.

    Cheers, Brian

  71. Re:A (hopefully) unbiased opinion on Perl v. Pytho by black+mariah · · Score: 1

    I don't know if I'd throw it into the "learning language" category. After all, that's throwing it into the same bin as BASIC and Pascal. Python's core language is just as good as any other. The problem with Python is the modules. Like you said, the documentation for these is HORRIBLE. For those that don't know, the documentation consists of whatever the programmer decided to put into triple quotes in the source. You can then run another program to go in and retrieve these, and format them appropriately. This sucks. I like Python, but the documentation definitely needs a kick in the ass.

    --
    'Standards' in computing only impress those who are impressed by things like 'standards'.
  72. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Peaker · · Score: 1

    Your blocks are obviously too large, then.
    You need to divide into smaller, more trivial pieces of code.

    Python is so expressive that functions/methods rarely need to exceed 5-8 lines.

    Show me any example of a long Python function where you have experienced what you speak of, and I'll explain how and why its too long.

  73. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Peaker · · Score: 3, Insightful

    But the problem is that Python suffers from a lot of Perl's problems
    Other than Performance?

    and adds a few of its own: you can't implement it in itself
    Hmm? Its quite trivial to parse Python code in Python, and its qutie trivial to interpret it with Python code, so where's the problem?

    it has no strong typing (even Perl's use strict is ridiculously better),
    You're confusing "strong typing" with "static typing". Python has no Static Typing, but indeed has Strong Typing (try '5 + "Hello"' in your Python interpreter). Perl, on the other hand, has no strong typing at all ("Hello" + 5 is perfectly valid in Perl, albeit senseless).
    Not having Static Typing is not a bad thing - its a concious decision by the language designers. The designers of Python wanted the language to be just-explicit. If you want the program code to express an idea, you express it once - Which is more than implicit, and less than redundant. Static typing is redundant - and avoided in Python as a design goal of minimizing programming time of any task.
    Another idea behind the lack of static typing is that all lines of code MUST run at least once anyway for any minimal level of reliability, so the compilation-level check adds no value.

    an OO system with no support for data hiding, etc. etc.
    Python supports data-hiding, but simply does not enforce it. This is because Python is not a BDL (Bondage and discipline langauge). Instead, there are extremely well-established and documented Python conventions. The prefix underscore that denotes private/protected, The double underscore that
    denotes private (avoiding namespace clashing by name mangling), etc.
    And that brings me to the biggest problem: Python doesn't really have a niche to fill. The CGI space has been seemingly co-opted completely by Perl (at least until people start using PHP), and it's too dog-slow to be used for real CS applications.
    Python isn't a niche language. Its a general-purpose language - and no - its far from being too slow for real CS applications. That's why its successfully used in Search engines, 3d engines, system administration, compilers, games, etc.
    As a beginner's language it's ideal, but that's not going to help it be taken seriously when it comes to real computing tasks.
    Python is taken very seriously in many many places, with increasing seriousness.

    If the python developers made some tweaks to the type system
    Like what? Static typing conflicts with the Python design goals.
    and added a real compiler
    Python already has the Jython compiler to Java, psyco compiler to native code, and others.
    then I would advocate that most software engineering be moved there.
    Many already advocate it for all software engineering except for the inner loops which are exported to Python from C code. This proves for many people to be the most effective way to write fast, reliable maintainable code.
    As it stands it's an original language which is a lot of fun to program in, and still has lots of unmapped potential to it.
    The unmapped potential is discovered by more people every day :)

  74. Re:A (hopefully) unbiased opinion on Perl v. Pytho by glyph · · Score: 1
    Hi,
    implement it in itself: Not sure what your point is, but you can certainly implement the Python VM in itself. The Python VM is actually quite portable as is demonstrated by the excellent Java based implementation found in Jython.
    PyPy is an implementation of the python interpreter, in python, that is seeking to optimize the interpreter. Is there any similar project in Perl?
    Too dog slow? Uh, no. See the Twisted project for an example of an "internet event server" whose web server implementation is faster-- and more flexible-- than apache.
    Umm... not to look a gift horse in the mouth, but, do you have any numbers on this? As far as I know, Twisted is only faster than Apache on some configurations of MacOS X. Generally it benchmarks slower. We have a lot of optimization left to do in that arena. Of course, twisted.web has been powering our moderately high-traffic site for well over a year at this point, as this graph will show, and we've had zero performance problems.

    Twisted Web is "fast enough", and nobody seems seriously interested in optimizing it, but I would hesitate to boldly claim it's "faster than" something else if it doesn't have a clear advantage. I'd have no problem if you said it was faster than Jigsaw, for example: if you want to talk about dog-slow systems, that's a good example.

    With a real production webserver like Apache, though, there are a lot of variables to tune. There are obscure interactions to be taken into account. Twisted will surely be slower than well-configured Apache on an SMP system, for example, unless you've got 2 processes working in parallel behind a proxy... and of course, then there's dynamic content, which is an entirely different set of measurements.

    The issues are complex, and it doesn't help to advocate the project by oversimplifying them.

    --
    Glyph Lefkowitz - Project leader, Twisted Matrix Labs
    Writer, Programmer - Not a member of the TSU
  75. Re:A (hopefully) unbiased opinion on Perl v. Pytho by demi · · Score: 1

    Well, relocating all the logic into a dozen separate function calls doesn't necessarily help readability either--sometimes you want to see a bit of sequential logic. There was some of that going on, and a couple of large here-documents.

    But of course I'm not claiming that the problem can't be solved or even that there's anything wrong with Python, just that the poster was clearly baiting people with the claim that Perl coders don't like Python's indenting-based blocks because it doesn't allow them to write ugly code, which is clearly an insult.

    I appreciate your offer to write some code for me though :)

    --
    demi
  76. Python Essential Reference/New Riders by syrah · · Score: 1

    I love O'Rielly books. I have not seen the python book this review addresses, but I didn't like O'Rielly's previous Python books. Assuming you already know how to program in some language, the Python book I would recommend is _Python Essential Refernce_ by Beazley published by New Riders. It is the book O'Rielly doesn't have. I agree with the others who have recommended it.

    --
    (This post probably would have been more coherant if I had spent more attention writing it.)
  77. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Troll_Kamikaze · · Score: 1

    You can address this problem with one or more of the following:

    - a folding editor (SciTE, PythonWin, jEdit, ...)

    - block delimiters placed in a comment, like:
    if x: #{
    ...
    ...
    #}

    - a preprocessor that Tim Peters wrote to strip block delimiters automatically before the code is sent to the interpreter

  78. Python focuses on practicality; deserves study by Anonymous Coward · · Score: 0

    Python has its quirks (what doesn't?!) but the key thing to remember is that it's been designed with practicality as the #1 design metric. Sure, you can complain about the object model not being pure in one way or another, or any number of other things. But that is missing the point. The bottom line is that it's a phenomenally easy language to work with, and it results in clear and very maintainable code.

    It's a language for people that focus on results and not for language lawyers or people that think complexity or obfuscation is cool. It requires some willingness to learn and understand how to work in it, but the rewards are well worth breaking through the "yuck, white space = syntax" and related mindsets.

    I personally learned it from the online docs and by working with a real application that I needed to write as fast as possible. It's quick to get started that way tho I realize now that I missed the point often enough that reading a "real" book might have helped me take better advantage of the language earlier on.

    Anyway, it's a very well thought out language and deserves study through actual use. Quick to learn, rewarding very early on, but also does take some time to use optimally. This is particularly true in learning how to write performance critical code, and in figuring out how to take advantage of the dynamic nature of the language. The latter can be very powerful w/o danger of reducing code maintainability; something quite surprizing that I've never seen in any other language design.

    I know nothing about this book, but hopefully this perspective of an ex-skeptic is useful.

  79. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Troll_Kamikaze · · Score: 1

    I'm not sure what "real CS applications are" but Python is frequently used for scientific computing.

    "Real CS applications" are programs written by Real Programmers--the "anything less efficient than asm is an abomination" crowd.

  80. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Troll_Kamikaze · · Score: 1

    Some Python developers argue continuation does not bring enough benefit. I think it's shortsighted...

    This isn't the primary reason that stacklessness hasn't become standard. The foremost reason is that the Java Virtual Machine (upon which Jython is implemented) can't handle tail recursion efficiently.

    Guido wants to avoid significant divergence between CPython and Jython; he argues that people would be much more likely to write Jython-incompatible code if they were able to take advantage of stackless features in CPython.

    Like you, I don't agree with his decision.

  81. Another alternative to Learning Python by Big+Sean+O · · Score: 1

    Another book for adults...

    Learning Python is getting rather dated (version 1.5 or sumthin). As an alternate, I can recommend Peachpit's Visual Quickstart Guide Python by Chris Fehily. It's a thorough, well designed introduction for people who like to learn while doing. Most of the examples are done at the interactive prompt.

    The chapters are well laid out and progress rationally: the separate chapters on Numbers, Strings, Lists, and Dictionaries are followed by Control Statements. Eventually Modules, Classes, and Exceptions are introduced.

    At first impression, the visual quickstart layout is mostly wasted here. There aren't many screenshots to show. Most of the visuals are the interactive sessions explained in the surrounding text. However, the double column style of the quickstart guide flows better than a single column with examples peppered thoughout. For example, if you get the text description, you can just keep reading. You can cut over to the figures when you need more claification.

    The Python book is newer, larger, and cheaper than O'Reilly's Learning Python. I think it's also a better introduction to the language. Programming students will appreciate the logical pace, and experienced programmers that are new to Python will like the well-organized chapters.

    As regards to Python in a Nutshell, if you want a dead-tree reference, that covers all of the main concepts of the language thoroughly (and frequently insightfully), then this book is for you.

    --
    My father is a blogger.
  82. Re:A (hopefully) unbiased opinion on Perl v. Pytho by glwtta · · Score: 1
    Sigh. Since apparently it's useful to specify our linguistic orientation at the beginning: I work in Java and Perl for the most part, I am at least familiar with most other popular languages (I am not sure if I would go as far as "smattering" though), oh and I like Perl.

    Ok, so your problems with perl are how it's designed, that it can't be implemented in terms of itself (wtf?), that you have to security audit it (what do you usually do? hope really hard that it's secure?) and apparently it would be better off being whitespace sensitive. Oh and I am sure that first type functions are somehow supremely better than sub refs.

    Then you proceed to sneer at the concept of "practical". Hm, can you tell me how any of that affects software development (that which we, in the real world, use programming languages to accomplish)?

    Out of curiosity, when you say "The CGI space has been seemingly co-opted completely by Perl", do you believe that everyone else is just stupid, and only you can see that this awful, awful language shouldn't be used at all? Incidentally, your assertion that PHP is somehow the logical successor to Perl to completely take over webapps leaves me doubting if you are as familiar with either, as you claim to be ("smattering" is a pretty strong term, after all).

    Of course Perl has it's share of faults, every language has faults, posting long diatrabes about how certain languages are useless based half on stupid cliches and half on really esoteric "problems" is a fetish even worse than being a language zealot.

    be a programming zealot, learn as many languages as possible, and which one to use in a given situation.

    This is all nice and dandy, but at some point you come to realize that there are only about half a dozen commonly used languages out there, and that at any one place of employ you are likely to be using only two or three of them, at most; and that at some point you have to start worrying about getting shit done (and quickly) rather than selecting a language most perfectly ideal to the task at hand; because in the end, the time they are paying you for is more valuable than your arbitrary aesthetics.

    For those wondering why I took the time to answer a stupid clueless diatribe with an angry "biased" diatribe - I'm waiting for clustalw to finish running before I go home, and have little else to do :)

    --
    sic transit gloria mundi
  83. Is Python Good for Learning? by Vagary · · Score: 1

    As a grad student who may someday be teaching introductory CS courses and thinks the current C-or-Java approach is lacking, I think quite a lot about pedagogical languages. As much as I may enjoy programming in Python, I have serious doubts about its suitability in this area. Lets evaluate the languages you mention:

    • C/ASM: rough learning curve and not practical for upper-year courses with OO (neither C++ nor Objective-C seems suited for teaching) but the students can grasp what's really going on and learn about low-level goodies.
    • Java: not elegantly designed and too complex to even come close to mastering in the first year but prized in industry (or at least students think so).
    • Perl: Yeah, right.
    • Lisp/Scheme: elegant implementation and yet immensely useful for teaching theoretical concepts, however I think the extreme dynamic typing is starting to show its age.
    • Python: not simple, not theoretically interesting, not especially elegant, not used in industry. Python seems to fall just short of every criteria. Not really short, but too short.

    I think Python needs two things before I'd reconsider it as a teaching language:

    1. A bit more exposure in industry so students don't say "what the fuck is Python?" in the first lecture.
    2. Idealised Python: A more elegant, minimalist, simplistic version to start the students out on and which could conceivably be implemented in a half-year course.
    1. Re:Is Python Good for Learning? by Anonymous Coward · · Score: 0

      Common Lisp also has static typing. You just don't *have* to use it. And even if you do, with a type-inferencing Lisp compiler like CMUCL (that's CL, not ML, obviously), you don't notice it so much. Scheme is used in CompSci a lot because of its elegance and purity and because of the call/cc love-in, but you can Actually Do Real Stuff in Common Lisp.

  84. A CSist Reponse by Vagary · · Score: 1

    As a CompSci grad student, I don't fully trust something until I understand what it's doing under the hood or see at least semi-formal justification. If Python wants to be a serious teaching language, it either needs massive industry use (Java), simple implementation (Scheme & C), or very elegant semantics (Scheme & Haskell) -- right now it is nowhere close to having any of these.

  85. Well it's obvious you live under a rock. by Peter+Cooper · · Score: 1

    and it is doubtful that Perl will ever be re-implemented ever again. It's obvious you don't read Slashdot, or even keep up with the latest programming news. Perl is under heavy reimplementation right now. Indeed, Larry Wall publishes a new tome of information about the rearchitecture every few months. The Parrot team are working on a VM for the language, upon which other languages like Ruby are even planned to be re-implemented. Get with the times :-)

  86. Re:A (hopefully) unbiased opinion on Perl v. Pytho by JohnFluxx · · Score: 1

    have you not tried any functional languages at all?

  87. A python in a Nutshell... by s-orbital · · Score: 1

    If pythons can eat pigs, how can they fit in nutshells? But then again, how does cowboy neal fit in that chair?

    --
    Patent: from Latin patere, to be open
  88. lost...for sure by djupedal · · Score: 1

    Nail on the head.... I got half way thru the thing and wanted to tell him to get a room already...

    Too bad an otherwise positive review got lost in a fan-boy parade.

    I think it was the contrast between nutshell and 600+ pages that threw me first...then the full-frontal fandom sunk in and I signed off an any credibility.

    Oh well, one man's Grey Poupon, another man's Shoe-Goo.

  89. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Sleepy · · Score: 1

    Granted, MORE documentation is always helpful but the """ convention itself is awesome.

    you can access the text using:
    modulename.__doc__

    This is VERY convenient.

    I can document my code --and-- give others a hook for getting additional info, generating reports, etc. It's good for outputting -help, usage, higher loglevels, etc.

    I think Perl has the same mechanism, but I don't see it in common use within commercial groups.

    I may be overstating the "horrible documentation" a bit also. There's bad documentation for Perl also, particulary thirdparty modules (which is what I was using for my Python example... win32 isn't exactly core Python).

    Also, by "learning language" I wasn't attempting to deride Python -- which I love. It's appealing to novices because it's clean and safe to experiment with. Python just needs a bigger user base.

  90. Classes versus prototypes by smallpaul · · Score: 1

    As to the object system: my general feeling, and I think the feeling of most people who've used both class-based and proto-based models, is that proto-based models are much more flexible and intuitive. You need a good reason to use a class-based model. Typically the reasons are either (1) speed or (2) compile-time bug-checking via strong typing. Both are good reasons.

    You are complaining about the implementation of one Python interpreter, known as CPython. Jython compiles Python classes to Java classes. Anyhow, I don't share your impression that prototype-based inheritance is so wonderfully flexible and intuitive. After all, Smalltalk uses classes and is widely cosnidered to be both flexible and intuitive.

    Python is absolutely not an experimental language. At the time Python was invented Javascript didn't even exist, and Javascript has hardly shown off the beauty of prototype-based inheritance. How many programmers do you know who have tried any of the other prototype languages? Python makes the same choice as Simula, Smalltalk and the various languages inspired by those two including C++, Java, C#, Ruby, Perl. On the other side of the issue we have what, JavaScript and Self (and several other experimental languages)?

    I'm not saying that class-based is necessarily better than prototype-based. I'm saying that you need more evidence than simply asserting that "people who know" say that prototype-based is better.

  91. No need for __DIE__ hooks by smcv · · Score: 1

    I've actually used this sort of exception-handling at work, for an unexpected but not fatal condition in a program where next and last weren't suitable. You don't need $SIG{__DIE__} hooks, and in fact they're officially frowned upon by the Perl 5.x developers - instead, you wrap the whole thing in an "eval", which catches exceptions, then test a special "error" variable which contains the exception, or a false value if there wasn't one.

    Catching all exceptions is bad (I still wanted my program to die on I/O errors), so you have to be a bit selective.

    eval { # this is like "try"

    while()
    { ...
    if($need_to_terminate)
    { # this is like "throw"
    die "Terminating loop";
    } ....
    }

    }

    # this next bit is like "catch"
    # I forget exactly what the punctuation is; I *think* it's $? you need to look at though
    if($?)
    {
    if($? eq "Terminating loop")
    {
    warn "Non-fatal exception, carrying on";
    # or whatever else you want to do
    } else {
    die; # re-throw the exception to let someone else handle it
    }
    }

    The exceptions can be objects instead of strings, too.

    I've also used this mechanism for a sort of more user-oriented "stack trace": the parse_line function (which doesn't know where its data came from) dies on errors, with a message which includes the offending line of a file, while the parse_file function catches exceptions provided by parse_line, adds something like "Error was in /home/smcv/foo.log line 345" to the error message, and re-throws the exception.

    (It's generally useless to users of a logfile-mangling program to see where the error happened in your code, unless they start debugging your program, in which case they can turn on Carp for themselves; what's useful is to see where the error was in the format of their input file.)

  92. Python is powerful and easy by Anonymous Coward · · Score: 0

    Python is a powerful language, with excellent object oriented behavior as well as good features for functional style programming. It is also quite easy to learn and use. Using Python, many programmers can improve their productivity by 5 to 10 times compared to using, say, C++ or Java. These productivity savings are real. Python is used to produce large, complex systems such as Zope. It is well worth your time to look into Python.

  93. Re:A (hopefully) unbiased opinion on Perl v. Pytho by Sleepy · · Score: 1

    >...might be why the Python win32 documentation isn't very strong: it is not done by the core Python team, nor by a company that charges you money, but by one really smart guy (Mark Hammond) who, in addition to doing work that pays the bills, develops and documents the Python win32 bindings pretty much by himself.

    >I think that the core Python library reference is excellent.

    I back away from my statement. I'm one of those people who bitches about missing Linux manpages, or manpages that refer only to the INFO pages. I am an ass, OK? :-)

    I realize - now - there's only a small group on win32-python. For some reason I though ActiveState and others were funding efforts to make the environment better documented and more formal.

    I don't know who Mark works for, but I can say he IS helping me with my question which I posted to the list. I also bought his book to further my efforts (but it doesn't cover this API in question).

    I may have worded things poorly, but the intent was to say there are a lot of rough edges, and a lot of "learning" users (like me), but it would probably improve if more power/commercial users started using it. Most people on Win32 just use VB so there's tons of independent docs.

  94. Re:A (hopefully) unbiased opinion on Perl v. Pytho by mzipay · · Score: 1

    wow.
    i'm fascinated by your post because i find myself *wishing* that other languages had documentation like python's. aside from java (whose online documentation just flat-out rocks, imho), i can't think of another language that has better documentation available.
    i'd be very interested in hearing some specific examples that would explain your vehement hatred of Python's documentation. is it the format of the docs? do you feel the docs don't provide enough info?
    in my experience (i've been using python for six years; since v1.3), the documentation is top-notch and one of the main reasons i am able to develop rapidly in the language. can you offer a more in-depth description of the problems you find in it?