Beta

×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Python in a Nutshell

timothy posted more than 11 years ago | from the panicking-the-nuts dept.

Programming 246

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.

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."

cancel ×

246 comments

Sorry! There are no comments related to the filter you selected.

IN SOVIET RUSSIA (-1)

IN SOVIET RUSSIA (621411) | more than 11 years ago | (#5744110)

Book reviews you!

If only Ike were here (-1)

Anonymous Coward | more than 11 years ago | (#5744128)

I sure do miss Old Ike... :(

cum on me (-1, Troll)

Anonymous Coward | more than 11 years ago | (#5744116)

A Guide to Self-Control:
1. Never touch the intimate parts of your body except during normal toilet processes.

2. Avoid being alone as much as possible. Find good company and stay in this good company.

3. If you are associated with other persons having this same problem, YOU MUST BREAK OFF THEIR FRIENDSHIP. Never associate with other people having the same weakness. Don't suppose that two of you will quit together, you never will. You must get away from people of that kind. Just to be in their presence will keep your problem foremost in your mind. The problem must be taken OUT OF YOUR MIND for that is where it really exists. Your mind must be on other and more wholesome things.

4. When you bathe, do not admire yourself in a mirror. Never stay in the bath more than five or six minutes -- just long enough to bathe and dry and dress AND THEN GET OUT OF THE BATHROOM into a room where you will have some member of your family present.

5. When in bed, if that is where you have your problem for the most part, dress yourself for the night so securely that you cannot easily touch your vital parts, and so that it would be difficult and time consuming for you to remove those clothes. By the time you started to remove protective clothing you would have sufficiently controlled your thinking that the temptation would leave you.

6. If the temptation seems overpowering while you are in bed, GET OUT OF BED AND GO INTO THE KITCHEN AND FIX YOURSELF A SNACK, even if it is in the middle of the night, and even if you are not hungry, and despite your fears of gaining weight. The purpose behind this suggestion is that you GET YOUR MIND ON SOMETHING ELSE. You are the subject of your thoughts, so to speak.

7. Never read pornographic material. Never read about your problem. Keep it out of mind. Remember -- "First a thought, then an act."

The thought pattern must be changed. You must not allow this problem to remain in your mind. When you accomplish that, you soon will be free of the act.

8. Put wholesome thoughts into your mind at all times. Read good books -- Church books -- Scriptures -- Sermons of the Brethern [sic, Cistern too?]. Make a daily habit of reading at least one chapter of Scripture, preferably from one of the four Gospels in the New Testament, or the Book of Mormon. The four Gospels -- Matthew, Mark, Luke and John -- above anything else in the Bible can be helpful because of their uplifting qualities.

9. Pray. But when you pray, don't pray about this problem, for that will tend to keep [it] in your mind more than ever. Pray for faith, pray for understanding of the Scriptures, pray for the Missionaries, the General Authorities, your friends, your families, BUT KEEP THE PROBLEM OUT OF YOUR MIND BY NOT MENTIONING IT EVER -- NOT IN CONVERSATION WITH OTHERS, NOT IN YOUR PRAYERS. KEEP IT _OUT_ of your mind! The attitude of a person toward his problem has an affect on how easy it is to overcome. It is essential that a firm commitment be made to control the habit. As a person understands his reasons for the behavior, and is sensitive to the conditions or situations that may trigger a desire for the act, he develops the power to control it.

As one meets with his Priesthood Leader, a program for overcoming masturbation can be implemented using some of these suggestions. Remember it is essential that a regular report program be agreed on, so progress can be recognized and failures understood and eliminated.

Suggestions:
1. Pray daily, ask for the gifts of the Spirit, that which will strengthen you against temptation. Pray fervently and out loud when the temptations are the strongest.

2. Follow a program of vigorous daily exercise. The exercises reduce emotional tension and depression and are absolutely basic to the solution of this problem. Double your physical activity when you feel stress increasing.

3. When the temptation to masturbate is strong, yell STOP to those thoughts as loudly as you can in your mind and then recite a prechosen Scripture or sing an inspirational hymn. It is important to turn your thoughts away from the selfish need to indulge.

4. Set goals of abstinence, begin with a day, then a week, month, year and finally commit to never doing it again. Until you commit yourself to never again you will always be open to temptation.

5. Change in behavior and attitude is most easily achieved through a changed self-image. Spend time every day imagining yourself strong and in control, easily overcoming tempting situations.

6. Begin to work daily on a self-improvement program. Relate this plan to improving your Church service, to improving your relationships with your family, God and others. Strive to enhance your strengths and talents.

7. Be outgoing and friendly. Force yourself to be with others and learn to enjoy working and talking to them. Use principles of developing friendships found in books such as How to Win Friends and Influence People by Dale Carnegie.

8. Be aware of situations that depress you or that cause you to feel lonely, bored, frustrated or discouraged. These emotional states can trigger the desire to masturbate as a way of escape. Plan in advance to counter these low periods through various activities, such as reading a book, visiting a friend, doing something athletic, etc.

9. Make a pocket calendar for a month on a small card. Carry it with you, but show it to no one. If you have a lapse of self control, color the day black. Your goal will be to have no black days. The calendar becomes a strong visual reminder of self control and should be looked at when you are tempted to add another black day. Keep your calendar up until you have at least three clear months.

10. A careful study will indicate you have had the problem at certain times and under certain conditions. Try and recall, in detail, what your particular times and conditions were. Now that you understand how it happens, plan to break the pattern through counter activities.

11. In the field of psychotherapy there is a very effective technique called aversion therapy. When we associate or think of something very distasteful with something which has been pleasurable, but undesirable, the distasteful thought and feeling will begin to cancel out that which was pleasurable. If you associate something very distasteful with your loss of self-control it will help you to stop the act. For example, if you are tempted to masturbate, think of having to bathe in a tub of worms, and eat several of them as you do the act.

12. During your toileting and shower activities leave the bathroom door or shower curtain partly open, to discourage being alone in total privacy. Take cool brief showers.

13. Arise immediately in the mornings. Do not lie in bed awake, no matter what time of day it is. Get up and do something. Start each day with an enthusiastic activity.

14. Keep your bladder empty. Refrain from drinking large amounts of fluids before retiring.

15. Reduce the amount of spices and condiments in your food. Eat as lightly as possible at night.

16. Wear pajamas that are difficult to open, yet loose and not binding.

17. Avoid people, situations, pictures or reading materials that might create sexual excitement.

18. It is sometimes helpful to have a physical object to use in overcoming this problem. A Book of Mormon, firmly held in hand, even in bed at night has proven helpful in extreme cases.

19. In very severe cases it may be necessary to tie a hand to the bed frame with a tie in order that the habit of masturbating in a semi-sleep condition can be broken. This can also be accomplished by wearing several layers of clothing which would be difficult to remove while half asleep.

20. Set up a reward system for your successes. It does not have to be a big reward. A quarter in a receptacle each time you overcome or reach a goal. Spend it on something which delights you and will be a continuing reminder of your progress.

21. Do not let yourself return to any past habit or attitude patterns which were part of your problem. Satan Never Gives Up. Be calmly and confidently on guard. Keep a positive mental attitude. You can win this fight! The joy and strength you will feel when you do will give your whole life a radiant and spiritual glow of satisfaction and fulfillment.

8CzC8CbC-ONE EYED DUTCHMAN-z8b5z8b1z8b5z8b5z/- \
8b1z8b5z8b5z8b1z8b5-TROUSER SNAKE-8z5b8z1b8|MCUM \
5z8b5z8-PENIS-1b8z5b8z5b8z1b8z-FINELINER-b5|8CU MM |
5z8b1z8b5z8b5z8b-KNOz-1b8z5b8z5b8z1b8z5b8z5|MCU MM-| Ejaculation = Slashdot.
8b1z8b5z8b5z8b1z8b5z8b5z-JOHN THOMAS-b8z1b8|5CUMM |
8CzC5-L.T. CMDR DATA-b8z1b8z5b8z5b8z1b8z5b8z\____/

DON'T YOU HAVE TO CUM WHEN READING SLASHDOT?

TO JOIN THE TROLL-KORE, PLEASE INSERT THE FOLLOWING GREETING AT THE BOTTOM OF YOUR POST.

We are the lowest of the low trolls;
Trolling in-between bans.

- TROLL-KORE FOREVER
- I hate you, I hate your country, and I hate your face!
___
/ | \
|_____| -#trollkore
/|||||\ - irc.freedomirc.net
| o /\O |
| UUUUU | - Website: Coming soon, fagG0tZ!
\_____/
| | LOOK AT MY SHINY BELL,
| | AND MY HUMPED BACK!
| 8 | - Prince of Knobstradamus
|S S|
/8S8S8\
|8S8S8S8|
|S8S8S8S|
\__/__/

Ya, but does it make julian fries? (-1, Troll)

Anonymous Coward | more than 11 years ago | (#5744122)

Jeez, that had to be the most positive "review" I've ever read on /.

Nutshell?!? (5, Funny)

skillet-thief (622320) | more than 11 years ago | (#5744135)

634 Pages!?!

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

You ain't seen nothing yet. (5, Funny)

GoodFun!!!!!!!! (663891) | more than 11 years ago | (#5744200)

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.

Re:You ain't seen nothing yet. (0)

Anonymous Coward | more than 11 years ago | (#5744270)

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

Re:Nutshell?!? (0)

wisdom_brewing (557753) | more than 11 years ago | (#5744229)

634 pages?

can type but still cant read...

Re:Nutshell?!? (1)

skillet-thief (622320) | more than 11 years ago | (#5744322)

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

Re:Nutshell?!? (1)

0x00000dcc (614432) | more than 11 years ago | (#5744316)

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 ...

Re:Nutshell?!? (1)

sporty (27564) | more than 11 years ago | (#5744613)

Any smaller, the ASPCA would bitch :)

Gentoo Zealot translator! (2, Funny)

Anonymous Coward | more than 11 years ago | (#5744137)

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!"

-

Re:Gentoo Zealot translator! (0, Offtopic)

n1cad (588005) | more than 11 years ago | (#5744516)

best. post. ever

Re:Gentoo Zealot translator! (Mod this post) (0, Offtopic)

soorma_bhopali (643472) | more than 11 years ago | (#5744573)

This is the damn good post. Mod this post up

Where's the review? (5, Insightful)

campbellkid (663975) | more than 11 years ago | (#5744144)

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"?

An Appropriate Receptacle (1, Funny)

ddillman (267710) | more than 11 years ago | (#5744183)

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!

teh snakex0rs (-1, Offtopic)

WeenisMonster (664473) | more than 11 years ago | (#5744199)

you unimaginative fool, can't you break free from your literalist reality and imagine the possibilities when teh snakex0rs are freed from their nutshells? Let's hope you can take a lesson from this book and "cover it all," including hopefully your head with a plastic bag.

Re:Where's the review? (4, Insightful)

josephgrossberg (67732) | more than 11 years ago | (#5744478)

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".

A challenge to smart people... (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5744146)


Can any smart/bright/intelligent reader really read the complete content of this page and really understand it ?

The ultimate truth and nature of universe from human's percpective [jainstudy.org]

Re:A challenge to smart people... (1, Funny)

Anonymous Coward | more than 11 years ago | (#5744195)

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.

Python == Snake Oil (-1, Troll)

Anonymous Coward | more than 11 years ago | (#5744161)

Python is a hideous kludge; possibly the only programming language scam worse than Java.

Re:Python == Snake Oil (1)

jejones (115979) | more than 11 years ago | (#5744182)

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.)

Re:Python == Snake Oil (1)

B3ryllium (571199) | more than 11 years ago | (#5744291)

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.

And now for something completely different... (3, Funny)

WIAKywbfatw (307557) | more than 11 years ago | (#5744164)

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.

Re:And now for something completely different... (1)

wirde (653827) | more than 11 years ago | (#5744194)

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...

Re:And now for something completely different... (2, Informative)

liquidsin (398151) | more than 11 years ago | (#5744234)

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

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

Re:And now for something completely different... (1)

iplayfast (166447) | more than 11 years ago | (#5744301)

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?

Re:And now for something completely different... (0)

Anonymous Coward | more than 11 years ago | (#5744578)

What's the difference between a duck?

One of its legs is both the same.

Re:And now for something completely different... (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5744242)

"Assaulted", not "assorted".

Salted peanuts, see, bach?

Re:And now for something completely different... (0)

Anonymous Coward | more than 11 years ago | (#5744679)

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

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

A (hopefully) unbiased opinion on Perl v. Python (5, Insightful)

Anonymous Coward | more than 11 years ago | (#5744165)

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.

Perl v. PHP (2, Insightful)

Anonymous Coward | more than 11 years ago | (#5744205)



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!

Re:A (hopefully) unbiased opinion on Perl v. Pytho (5, Insightful)

raju1kabir (251972) | more than 11 years ago | (#5744276)

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.

Re:A (hopefully) unbiased opinion on Perl v. Pytho (2, Interesting)

Anonymous Coward | more than 11 years ago | (#5744370)

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).

Re:A (hopefully) unbiased opinion on Perl v. Pytho (2, Interesting)

Anonymous Coward | more than 11 years ago | (#5744375)

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.

Re:A (hopefully) unbiased opinion on Perl v. Pytho (0)

Anonymous Coward | more than 11 years ago | (#5744409)

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.

Pet Python problems (1, Offtopic)

Ed Avis (5917) | more than 11 years ago | (#5744285)

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.

Re:Pet Python problems (3, Informative)

spareparts (398231) | more than 11 years ago | (#5744378)

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.

Re:Pet Python problems (1)

skinpup111 (531095) | more than 11 years ago | (#5744380)

- 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.

Re:Pet Python problems (2, Informative)

Kidbro (80868) | more than 11 years ago | (#5744385)

- 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.

Re:Pet Python problems (5, Informative)

Frater 219 (1455) | more than 11 years ago | (#5744404)

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. [activestate.com]

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.

Re:Pet Python problems (3, Informative)

frankie_guasch (164676) | more than 11 years ago | (#5744585)

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

Perl has exception handling with die/eval. Here is an article [perl.com] about it.

Re:Pet Python problems (1)

Ed Avis (5917) | more than 11 years ago | (#5744598)

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.)

Re:Pet Python problems (1, Informative)

Anonymous Coward | more than 11 years ago | (#5744418)

> - 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.

Re:Pet Python problems (1)

obsidian head (568045) | more than 11 years ago | (#5744650)

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.

Re:Pet Python problems (4, Informative)

tal197 (144614) | more than 11 years ago | (#5744440)

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 [sourceforge.net]
Writing GTK applications in python [sourceforge.net]

Re:Pet Python problems (1)

obsidian head (568045) | more than 11 years ago | (#5744604)

- 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 [paulgraham.com]
Function attributes [google.com]

Re:A (hopefully) unbiased opinion on Perl v. Pytho (3, Insightful)

Anime_Fan (636798) | more than 11 years ago | (#5744330)

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.

Re:A (hopefully) unbiased opinion on Perl v. Pytho (0)

Anonymous Coward | more than 11 years ago | (#5744469)

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.

Re:A (hopefully) unbiased opinion on Perl v. Pytho (5, Insightful)

tuffy (10202) | more than 11 years ago | (#5744338)

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.

Python's niche (2, Interesting)

vivek7006 (585218) | more than 11 years ago | (#5744667)

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++).

Re:A (hopefully) unbiased opinion on Perl v. Pytho (2, Informative)

john_roth (595710) | more than 11 years ago | (#5744347)

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

Re:A (hopefully) unbiased opinion on Perl v. Pytho (-1, Offtopic)

cheese_wallet (88279) | more than 11 years ago | (#5744525)

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?

Re:A (hopefully) unbiased opinion on Perl v. Pytho (0, Informative)

Anonymous Coward | more than 11 years ago | (#5744359)

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 [perl.org] .

Re:A (hopefully) unbiased opinion on Perl v. Pytho (1, Insightful)

Anonymous Coward | more than 11 years ago | (#5744364)

> 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.

Re:A (hopefully) unbiased opinion on Perl v. Pytho (1)

Cryp2Nite (67224) | more than 11 years ago | (#5744372)

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

Re:A (hopefully) unbiased opinion on Perl v. Pytho (5, Insightful)

bbum (28021) | more than 11 years ago | (#5744394)

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....

Re:A (hopefully) unbiased opinion on Perl v. Pytho (1, Informative)

Anonymous Coward | more than 11 years ago | (#5744567)

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.

python is not slow (0)

Anonymous Coward | more than 11 years ago | (#5744395)

python is not slower than perl

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

Until people start using PHP? (2, Informative)

Surak (18578) | more than 11 years ago | (#5744447)

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

Re:A (hopefully) unbiased opinion on Perl v. Pytho (1, Insightful)

Anonymous Coward | more than 11 years ago | (#5744513)

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

Re:A (hopefully) unbiased opinion on Perl v. Pytho (1)

frankie_guasch (164676) | more than 11 years ago | (#5744558)

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

#/usr/bin/perl -T

Re:A (hopefully) unbiased opinion on Perl v. Pytho (4, Insightful)

mbaranow (610086) | more than 11 years ago | (#5744594)

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

French (-1)

Reikk (534266) | more than 11 years ago | (#5744166)

God bless the French for standing up against the crusade against Iraqi people.

Python (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5744168)

Python is the future.

Nutshells are the past.

So this book must be in the present.

Given the fact that 90% of all books are written by 1% of the population it's clear that we are being controlled by toads from another dimension if in fact other dimensions exist beyond this dimension which is where that 1% is located depending on how you look at it from different angles till it looks like a fried egg with hash browns on the floor being eatin by bandit dogs from planet x which is going to flip the magnetic poles of the earth killing that 1% that write books about things I don't understand and will never understand why birds laugh so much when I take showers during the winter months when it's cold in fact aren't almost all months winter months except along the equator where none of those %1 live unless they do which is another story what?

If it's Python... (-1, Funny)

Anonymous Coward | more than 11 years ago | (#5744176)

Shouldn't the picture be the famous squashing foot?

Very Pythonic (2, Informative)

Limburgher (523006) | more than 11 years ago | (#5744181)

I liked this review. Sparkling, fluffless and pythonic. Adjectival as well.

Also, in response to an earlier post, the fries are spelt Julienne. And are damn tasty.

I was surprised, but... (5, Informative)

Ed Bailey (1912) | more than 11 years ago | (#5744184)

...I found New Riders Python Essential Reference to be a far better introduction to the language. I eagerly waited for Python in a Nutshell to come out, but I found I kept gravitating back to my copy of Essential Reference (the second edition, btw).

I am normally never disappointed with an O'Reilly book, but I was in this case. I hope it's not the start of a trend for them...

Re:I was surprised, but... (1)

graveyhead (210996) | more than 11 years ago | (#5744571)

The Essential Reference is OK, but the version I have (Update to Python 2.1) the page numbers "drift" from the index and table of contents. After about halfway through the book, all index and TOC entries are off by at least a page or 2. This is more than mildly annoying when I am trying to look something up.

It looks to me like when they "updated to Python 2.1", they forgot to also upgrade to "book 2.1". Fair warning!

Pythonic? (2, Funny)

iworm (132527) | more than 11 years ago | (#5744192)

Dear Reviewer, what's with this constant use of "Pythonic"?

Would you wish to repeatedly read "Ceeish", "Fortranish", "Javanical", "Perlectic", etc? Mildly witty the first time, bleedin' annoying the fourth or fifth.

Thank you.

Re:Pythonic? (0)

Anonymous Coward | more than 11 years ago | (#5744246)

If President Bush can address the world and say nukeular, and we accept that, we have to allow others the same freedom. So bring on pythonic, pythonically, pythonificate, pythonilate, and pythonoriffic.

*Throws Oxford English Dictionary in chipper-shredder*

Re:Pythonic? (1)

B3ryllium (571199) | more than 11 years ago | (#5744268)

This is where "confuzzled" [beryllium.ca] comes in handy. It already even has "nucular". :)

Pythonic (3, Informative)

FuzzyDaddy (584528) | more than 11 years ago | (#5744265)

is a word often used in the Python community to describe something that fits well with the Python design philosophy.

Re:Pythonic? (1)

Ed Avis (5917) | more than 11 years ago | (#5744317)

'Perlish' is the word you are looking for. I don't think C, Fortran and Java have an equivalent word, perhaps because they don't have 'communities' in quite the same sense.

Oh, well. (5, Insightful)

rice_burners_suck (243660) | more than 11 years ago | (#5744197)


636 PAGES.

This review is quite positive. I'm sure some faults could be found in this book, but suppose for a moment that I take your word for it and assume that this book is perfect. In such a case, I wish that more programming books would be published like this one.

I don't currently use Python in my work but I increasingly find that language reference and instruction books are either too darn complicated or too darn simple. You either have to be a complete idiot, who has never seen a computer, let alone programmed one, in order to read a book written for such idiots; or you have to be an unnaturally staid and steadfast compiler writer to understand the endless maze of technical details published into thick volumes intended for such stalwart masters.

I find that some of the slimmer, older volumes on C are written in a very readable fashion that require neither of the above virtues. However, newer books make the subject too complicated. Books on C++ are beyond help. Sometimes I wonder if our programming languages are much too complicated and perhaps should be reduced to a small number of basic elements, such elements being combined through the use of multiple languages in order to accomplish a specified goal. On the other hand, doing so will make development much too difficult. As such, it is up to the authors of explanatory volumes to make available a desired level of detail while keeping the material readable. It is this balance that I seek in programming books. Until then, well, I'll have to keep writing small "test" programs to probe the features of the language and of the compiler.

Oh yeah... and of course, I would like these volumes to be of allowable length for reading in an afternoon or so. 636 pages sounds like a good length.

Re:Oh, well. (2, Insightful)

Blaine Hilton (626259) | more than 11 years ago | (#5744306)

I think this is a good point. IT seems for every language you have your "newbie" book, and then you have your advanced book. There is no standard middle of the road one usually. I believe this is in large part due to the speed of the industry. Languages that have been around longer such as C, C++, and perl seem to have many more books then Python or PHP.

Medical Anomaly? (4, Funny)

liquidsin (398151) | more than 11 years ago | (#5744213)

Your python shouldn't be in the nutshell, it should be hanging comfortably in front of it. You may want to have a doctor check that out...

Heres some useful python links (2, Informative)

hfastedge (542013) | more than 11 years ago | (#5744217)

Slashdot accepted something from python by me, and here it is again as I think its relevant. Python is just great :-)

http://slashdot.org/articles/03/03/11/1817203.shtm l [slashdot.org]

hfastedge [wikipedia.org] writes "Ok, now that 2 perl conferences have been mentioned, I've been brought over the edge. Python [python.org] is a language that is just as old, and arguably [www.amk.ca] better from: most importantly a uniform standard of readability (enforced by using whitespace [wikipedia.org] to delimit blocks (instead of {}), by avoiding overuse of cryptic symbols, and by a culture [python.org] that strives to keep innovations as "pythonic"), and a rich [python.org] development [python.net] community. Anyway, normally, there are Python events [python.org]

in Europe, and a trail at O'Reilly's OSCON. But now, there is a far
cheaper event taking place on March 24-28 in Washington DC: http://python.org/pycon/ [python.org] .



Examples of Python in action: , 1 [google.com] , 2 [pythonware.com] , 3 [oreillynet.com] , 4 [intelligen...rprise.com] , 5 [scipy.com] , 6 [onlamp.com] , 7 [pygame.org] "

O'Reilly's "Nutshell" books are their worst (4, Insightful)

josephgrossberg (67732) | more than 11 years ago | (#5744231)

Seriously, why would anyone want to pay $35 for something that isn't much different from the online documentation?

Learning Python was great, as was the Python Cookbook. They had something to offer beyond a documentation of Python features (an explanation and an exploration of them, respectively).

Unless you have no internet connection or just greatly prefer dead trees, I can't see why you'd get any of the "brown" books.

Has anyone here been pleased with O'Reilly & Associates' ever-present "... in a Nutshell" books? I'd be curious to hear what the appeal is.

Re:O'Reilly's "Nutshell" books are their worst (0)

Anonymous Coward | more than 11 years ago | (#5744423)

Python in a Nutshell knocks the bundled Python docs into the proverbial ditch.

Re:O'Reilly's "Nutshell" books are their worst (1)

happy_cynic (622310) | more than 11 years ago | (#5744445)

I guess it depends on which nutshell book you use. I have a well-worn "UNIX in a nutshell". A while back I used the section on sed to write a script that filtered text. Also it was good when I needed some more info on a command (I was too lazy to read through the man pages). At the time the price was less then 10 bucks. Personally I use on-line documention as much as possible,but there are times when a "ole-fashioned" book is the right tool to use.

No... (2, Funny)

The Mainframe (573877) | more than 11 years ago | (#5744277)

No, this is python in a nutshell:
"Help! I'm in a nutshell! How did I get in this awfully big nutshell? What kind of nut has a shell like this?"

Python (-1, Redundant)

All Names Have Been (629775) | more than 11 years ago | (#5744289)

Yeah .. that review is great and all. but does it have the one with the peasants talking about the government and stuff? That was really funny. Oh and the wooden rabbit!

How much does it cost to advertise on Slashdott? (5, Funny)

Pizaz (594643) | more than 11 years ago | (#5744299)

Deer Slashdott.com, I've decided to right a book witch will bee very relevant to your readership (i.e geeks and nerds). Although i've yet too decide on the subject material, im very much looking forward to getting rich quick. Eventually, win I finish my book, i'd like too submit a glowing pseudo review to slashdott which contains a link to an online bookstore so that geeks and nerds and can start making me rich right away. Do these sorts of advertisements cost very much? I'm taking a cours in righting and I'll be able to start on the book real soon after I pass these lessons. Thank you. Looking forward to hearing from you so that I can start on the path to richdom.

Re:How much does it cost to advertise on Slashdott (1)

PktLoss (647983) | more than 11 years ago | (#5744446)

Its FREE! Theres just one catch, the book must be published by a publisher with more credability to throw around than slashdot has karma.

Re:How much does it cost to advertise on Slashdott (0)

Anonymous Coward | more than 11 years ago | (#5744491)

Is this book going to be written in Engrish?

MOD THIS UP (0)

Anonymous Coward | more than 11 years ago | (#5744583)

Please, for the love of God, mod this up!

geeez (0)

Anonymous Coward | more than 11 years ago | (#5744319)

Think he liked the book?

The question is... (-1, Offtopic)

Bendebecker (633126) | more than 11 years ago | (#5744337)

What is the average flight speed of a nutshell laden swallow?

The Best Intro to Python (4, Informative)

avdi (66548) | more than 11 years ago | (#5744363)

By far the best programmer's introduction to Python (in fact, one of the best programmer's intros to any language) I've ever read is Mark Pilgrim [diveintomark.org] 's Dive Into Python [diveintopython.org] , a free online book.

python (-1, Flamebait)

Anonymous Coward | more than 11 years ago | (#5744371)

is an idiotic language.

Python Essential Reference (3, Informative)

mzs (595629) | more than 11 years ago | (#5744381)

The book I both used to learn python and continue to go back to as a very useful, detailed, and fairly complete reference is "Python Essential Reference" by the creator of SWIG David Beazley. (If you ever wanted to mix C, java, python, perl, tcl go to http://www.swig.org/ sometime.) There is a newer second edition out now but the orignial was laid out as a short tutorial chapter to get started in python, then several short chapters about language details (lexical matters, types, operators, control flow, functions, classes, modules, and I/O), and the typical chaper about installation and site issues. This first section is less than 90 pages, fantastic for people already familiar with programming that want to quickly learn the syntax of python so they can get immediately started with python coding.

Then there is Appendix A which gives a short description of all built in functions and exceptions followed by concise descriptions of most of the standard python modules circa 1.5.2 (the newer edition is probably 2.0-ish) that are detailed enough to use as reference. Appendix A also has short examples and detailed explanations with background information where it is beneficial in the descriptions. The module reference is divided into topical sections such as string modules, networking modules, and threading modules and modules with related or complimentary functionality are cross referenced.

Finally there is a short Appendix B that explains how easy it is to extend python with C modules and even a bit of how to embed the python interpretter into your own programs and libraries!

Most importantly the book is only 274 pages and has a very useful index when you want to use it as a reference. Together with the online documentation at http://www.python.org/doc/ this book is invaluable to me.

whaaa??? (0)

ptrangerv8 (644515) | more than 11 years ago | (#5744386)

And here I was, thinking it was a GOOD book, regarding, of course... MONTY Python...

Silly slashdot!

Why are all my comments modded? Oh, right, Karma = - Infinity (eternally fucking bad)

Obligatory Austin Powers quote... (0)

Anonymous Coward | more than 11 years ago | (#5744392)


No, this is Python in a nutshell: "Help! I'm Python in a nutshell! How did I get into this bloody great big nutshell? What kind of shell has a nut like this..."

moron weighting for the weakly top 40 (0)

Anonymous Coward | more than 11 years ago | (#5744522)

snakes? those megaslothownions are more like evile serpeNTs with flames coming out of their .asps. there's no nut's hell that's going to .contain them.

IT'll be like when the freemasons took the saracens, only won survivor(s)?

lookout bullow. fortunately, the hobbyist dogooders have a few land based aquarians, to help rebuild everything, following the last big bullast.

question on python's implementation (1)

Maimun (631984) | more than 11 years ago | (#5744579)

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!

Re:question on python's implementation (-1, Redundant)

Anonymous Coward | more than 11 years ago | (#5744661)

for i in xrange(1,600)

generates them as needed

Re:question on python's implementation (4, Informative)

thermostat42 (112272) | more than 11 years ago | (#5744668)

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

Better review of the same book (2, Informative)

Anonymous Coward | more than 11 years ago | (#5744595)

Cameron Laird: Book review: Python in a Nutshell [unixreview.com] "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 [pythonware.com]

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?
or Connect with...

Don't worry, we never post anything without your permission.

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>