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!

Learning Python, 4th Edition

samzenpus posted more than 3 years ago | from the read-all-about-it dept.

Books 163

thatpythonguy writes "Learning Python is a well-written book by an experienced Python trainer that has served the Python community well since the first edition was published in 1999. Now, at its fourth edition, this book by Mark Lutz arguably continues to be Python's bible." Read on for the rest of Ahmed's review.This book is addressed as an introductory text to programmers new to Python. Although people with no programming experience are not discouraged from reading it, they are warned that time is mostly spent teaching Python, not programming fundamentals. I agree with this picture, though from my own experience and those of others, the book is equally valuable to more experienced Python programmers both as a pseudo-reference and as an introduction to more advanced topics. The critical point here is that the book does not make assumptions about educational or vocational experiences and provides many examples; this renders the book approachable by a large audience.

Both Python 2.6 and 3.x are covered in this edition. However, the latest 3.x line is considered the reference from which variations in 2.6 are discussed when appropriate. This approach is logical; the new Python 3.x presents a major change to the language, but is not sufficiently dominant to warrant exclusive treatment.

This book discusses the Python language and excludes the Python standard and non-standard libraries. The latter are discussed in other places including Lutz's own Programming Python which stands at its third edition at the time of writing of this article. I find this division necessary because of size considerations and, in fact, this division did not exist in the first edition of the book! However, there is one topic that does not seem to fit the language/libraries divide, and that topic is packaging and deployment.

I will argue that there are not many (if any) books that discuss packaging and deployment of Python programs well. I will also argue that this topic should be included in the book being reviewed here since it is so essential to real Python programming. Since Lutz discusses the Python runtime environment, I do not think it detracts from the book's coherence to include a chapter on packaging.It is possible that the proliferation of various packaging and deployment options such as distutils, setuptools, pip, buildout, virtualenv, paver, fabric and others, is the reason for this exclusion. Or it could be that these tools are in a state of major flux that any text will become quickly outdated. If size is the reason for this exclusion, maybe Lutz or someone else can publish 'Packaing and Deploying Python' as a separate volume.

The book starts by building a case for the use of Python. Both the features of the language and its prominent users are discussed to build credibility. Then, the runtime environment is discussed: how to run programs in various ways on various operating systems and language interpreters.

Types and statements, which are at the core of any language, are discussed next. Notably, there is an excellent discussion of the topic of iterators and generators (also discussed in a later chapter). Functions, modules and classes are then introduced. The text also includes a discussion of general object-oriented programming (OOP) principles which I find to be invaluable as it brings the topic of classes to life.

Exceptions are introduced and discussed in detail. The placement here is appropriate since exceptions are now objects in Python so classes had to be discussed first. This chapter should prove to be especially useful for people migrating from other languages that do not have simple, yet effective, exception-handling constructs.

Finally, four advanced topics are covered: decorators, Unicode, managed attributes, meta-classes. I find the first two to be absolutely necessary for almost any system nowadays, even small ones! The atter two are not as ubiquitous, but should be useful to more experienced programmers.

I should mention here that the discussion of the topics discussed above does not stop at the basics but provides comprehensive coverage. This is evident in the discussion of concepts such as dynamic typing, inheritance order, iterators, generators, comprehensions, and functional programming, among many others. There is even an interlude on documentation and the pydoc library.

Like many programming texts, the book uses small programming examples (appropriately executed in the Python interactive shell). The small examples hope to capture the essence of the topic at hand, and that, it does well within the limitations of a small-scale context. But this fourth edition adds a new chapter on classes (Chapter 27) that contains a more realistic code example presented in a tutorial format.

In addition to examples, each chapter ends with a summary of the chapter's content as well as a quiz on that content. The quiz is immediately followed by its answers for easy reference. I have to admit that I do not use any of these two features, so I will not be able to comment on their efficacy.

Like many O'Reilly books, this is a well-written, coherent, and beautifully type-set book. I highly recommend it to anyone who wants to, or already does, program using python. It should help the novice in the transition to an excellent programming language or, otherwise, make an already familiar environment more powerful in the hands of veterans.

Ahmed Al-Saadi is a Software Analyst who works for a Montreal Python house. He wrote his first lines of code on a Sinclair ZX Spectrum+, though unfortunately not in Python at the time.

You can purchase Learning Python, 4th Edition from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

cancel ×

163 comments

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

So (-1, Troll)

Anonymous Coward | more than 3 years ago | (#31235700)

how much stock does Samzenpus own in O'Reilly? Nice Slashvertisement otherwise.

I'll believe it is not a Slashvertisement the moment there is a negative review about why a book was not worthwhile.

Re:So (0, Flamebait)

stoolpigeon (454276) | more than 3 years ago | (#31235982)

you should call it a $la$hverti$ement. That would make you even more right.

Re:So (-1, Troll)

Anonymous Coward | more than 3 years ago | (#31236364)

you should call it a $la$hverti$ement. That would make you even more right.

Wow you really addressed the issue raised by the GP and rigorously demonstrated why you believe it's not a valid suspicion. You didn't resort to childish mockery at all. With sound reasoning like that, you have clearly put to rest any and all who would ever wonder if there is a financial connection between Slashdot's contributors and whether various books receive favorable reviews. You did all of that while putting aside your own emotional response to hearing something you dislike so that you can understand this crazy notion of other people wondering things that you wouldn't. Good show!

Re:So (0)

Anonymous Coward | more than 3 years ago | (#31236434)

Way to be a douchemonger. Like, seriously. You respond with a bunch of sarcasm THAT GETS NOWHERE FURTHER THAN THE GP and then use some tone to imply that you are God or something. Your post sickens me. Scum like you need to stop posting or be wiped out of the gene pool. Amen.

Re:So (0)

Anonymous Coward | more than 3 years ago | (#31236918)

So A asks a reasonable if cynical question about a practice that is commonplace today (sponsored reviews, astroturfing, etc), B mocks him while contributing nothing to the conversation, C decides to call bullshit on B, and now that qualifies C as having "implied his status as a deity" to paraphrase you. I'd ask you to back that up with some logic but we both know you can't.

I sure wish you immature pantywaists would learn how to separate your bitchy, irritable, pathetic emotional reactions from reasonable behavior. And yeah, getting that pissy and wishing the death ("wiped out of the gene pool") of someone merely because he posts something you don't like qualifies as bitchy. Well actually I should not insult bitches like that. My bet? I think you're stoolpigeon and this time wanted to be a bitch without getting negative karma. In which case the post sickened you because it's true and you wish it weren't. Does it hurt, being not man enough to admit your post contributed nothing and instead trying to cover it up by wishing the death of a stranger?

Ain't it funny how the one who gets so offended because he thinks someone pretends to be God is the same person who feels qualified to decide who should post, reproduce, or even live? Nah, nothing hypocritical about that. Oh i'm sorry, was that too sarcastic for you?

Re:So (0)

Anonymous Coward | more than 3 years ago | (#31237234)

Meh, I was thinking the same thing myself, but I didn't want to waste the time replying. Here's [nimp.org] a little article I found on people incessantly telling each other to die in a fire, etc. In other words, don't take it seriously. It was posted by some guy taking a smoke break and needed a little laugh. You're going to get a heart attack from the stress inflicted upon you by people telling mild jokes. Take a chill pill and relax.

Slashvertisement? (-1, Flamebait)

Anonymous Coward | more than 3 years ago | (#31235706)

How much were you paid off to put this on the front page, samzenpus, or should I say DOUCHE?

Tag as SLASHVERTISEMENT (-1, Troll)

Anonymous Coward | more than 3 years ago | (#31235776)

n/t

Aren't we all supposed to be switching to Lua now? (1, Funny)

Anonymous Coward | more than 3 years ago | (#31235782)

Y'know. Just trying to keep up with the current trend.

 

Re:Aren't we all supposed to be switching to Lua n (1, Interesting)

Anonymous Coward | more than 3 years ago | (#31235988)

Ruby failed to make a dent in Python popularity, despite the rails fad over the last few years. Lua isn't really a match for either python or ruby.

Javascript may be the black horse here, because it serves an unique niche and is starting to get adoption outside that niche.

JavaScript is the language of the day today. (1, Insightful)

Anonymous Coward | more than 3 years ago | (#31236010)

Sadly, JavaScript seems to have become the fad language lately.

A lot of people who can only handle front-end web development thought Ruby would let them do something a bit more serious, so it had a pretty large hype wave while they were trying it out. But they've found even it too difficult, so they've abandoned server-side work in favor of client-side coding again. Unfortunately, this has to be done in JavaScript, since that's basically the only language supported by all major browsers.

It's a shame that we don't have Lua or Python in the browser instead of JavaScript. It'd make web development much more efficient. JavaScript is such a hack, and such a pathetic excuse for even a scripting language.

You can script Windows & Linux with Javascript (0)

Anonymous Coward | more than 3 years ago | (#31236572)

Phones too. Seems to be the "universal" scripting language.
 

Re:JavaScript is the language of the day today. (1)

jra (5600) | more than 3 years ago | (#31236950)

Well, that depends on whether you consider "requires the user to install one plugin once, for every site" constitutes "in the browser", since I'm pretty sure that's the present state of affairs on Mozilla, at least. Whether there's a browser-side plugin for python on IE, I don't know; I avoid IE whenever possible. Since I'm the IT director, it's *always* possible. :-)

JS vs. Lua (2, Interesting)

tepples (727027) | more than 3 years ago | (#31237144)

JavaScript is such a hack, and such a pathetic excuse for even a scripting language.

What makes JavaScript so much more of a hack than Lua? Both use prototype-based object systems. Perhaps your complaint is with the HTML DOM, but that would be the same whether you used Lua, Python, or JavaScript on top of it.

Cover art (2, Insightful)

Anonymous Coward | more than 3 years ago | (#31235834)

Soooo the language is called PYTHON and O'Reilly put some kind of rodent on the cover? Not, I don't know... a python?

Maybe if the rat was being eaten by a snake it would make sense...

Re:Cover art (5, Funny)

ultrabot (200914) | more than 3 years ago | (#31235898)

The rat is there because python is still learning.

Re:Cover art (2, Funny)

K. S. Kyosuke (729550) | more than 3 years ago | (#31236224)

The rat is there because learning pythons need school supplies, too.

Re:Cover art (3, Funny)

reverseengineer (580922) | more than 3 years ago | (#31236288)

Food for thought?

Re:Cover art (2, Informative)

DragonWriter (970822) | more than 3 years ago | (#31235974)

Soooo the language is called PYTHON and O'Reilly put some kind of rodent on the cover? Not, I don't know... a python?

They put a different animal on the cover of each book.

The python is, IIRC, on the cover of Programming Python.

Re:Cover art (3, Informative)

theskipper (461997) | more than 3 years ago | (#31236152)

A python appears on a previous O'Reilly book, "Python in a Nutshell" (ISBN 978-0-596-10046-9).

My assumption is that they don't use the same animal on more than one cover, correct me if I'm wrong.

Re:Cover art (1)

idontgno (624372) | more than 3 years ago | (#31237024)

I was about to mock you by pointing out the O'Reilly Perl libary is camel-centric, but looking at http://oreilly.com/pub/topic/perl [oreilly.com] , I am amazed at the zoo of critters in the Perl book list.

What this tells me is that I need a much higher budget for books.

Re:Cover art (0)

Anonymous Coward | more than 3 years ago | (#31238310)

Hopefully at least one of them is an oyster.

Re:Cover art (1)

clampolo (1159617) | more than 3 years ago | (#31237182)

Well, for Javascript they had a rhino. And then for Learning Javascript they had a baby rhino which I thought was pretty clever.

Re:Cover art (2, Funny)

Hatta (162192) | more than 3 years ago | (#31237576)

This time they should have used a dead parrot. One with beautiful plumage.

Re:Cover art (1)

An ominous Cow art (320322) | more than 4 years ago | (#31238486)

import parrots, fjords

p = parrots.Parrot(parrots.NORWEGIAN|parrots.BLUE)

for fjord in fjords.all():
    p.pine(fjord)

Traceback (most recent call last):
  File "parrot.py", line 4, in <module>
    p.pine(fjord)
AttributeError: 'ParrotType' object has shuffled off this mortal coil

Re:Cover art (1)

Caesar Tjalbo (1010523) | more than 3 years ago | (#31237702)

It's a great book but it has just a naked python on the cover, they forgot the nutshell.

Re:Cover art (1)

oldhack (1037484) | more than 3 years ago | (#31238198)

And that is the book I'd (very highly) recommend for experienced programmers new to Python.

Re:Cover art (1)

Capsaicin (412918) | more than 3 years ago | (#31238302)

A python appears on a previous O'Reilly book, "Python in a Nutshell"

If memory serves me correctly Learning Python was out in the 1st edition for some years before the Nutshell book was written.

Re:Cover art (1)

Ukab the Great (87152) | more than 3 years ago | (#31236416)

And then came the Python that ate the mouse that drank the Cocoa that sweetened Java that dissolved the Perl that replaced the Ruby that my father bought for zuzim.

Re:Cover art (2, Informative)

gpuk (712102) | more than 3 years ago | (#31236468)

IIRC, the python name is a homage to Monty Python and has nothing to do with the snake. Perhaps a knight sans arms would have been more fitting...

Re:Cover art (1)

mirix (1649853) | more than 3 years ago | (#31236690)

Correct, but there is plenty of snake related imagery with python. I always get a kick out of the IDE named "Boa Constructor".

Re:Cover art (1, Funny)

Anonymous Coward | more than 3 years ago | (#31236714)

A dead parrot!

Re:Cover art (0)

Anonymous Coward | more than 4 years ago | (#31238564)

A dead parrot!

Please don't spam this thread!

Re:Cover art (1)

Thantik (1207112) | more than 3 years ago | (#31237520)

It's called "Learning Python: Powerful Object-Oriented Programming."

Or for short: Learning Python: POOP.

Maybe that's why the rodent is there.

Maybe Hulk Hogan's biceps... (0)

Anonymous Coward | more than 4 years ago | (#31238546)

...would have been a better cover art image?

why? (1)

madddddddddd (1710534) | more than 3 years ago | (#31235962)

why learn python when there is C and PHP? both are better at what they do best and what python seemingly tries to bridge. if you think python is the answer, you are kidding yourself.

Re:why? (3, Informative)

mangu (126918) | more than 3 years ago | (#31236720)

I know you are trolling, but here's the answer:

1) Programming in Python is faster than in C, and Python lets you use C libraries where performance is needed. Python will not make C go away, but will let it be used where it's really needed.

2) Python is more secure and much more powerful than PHP. With a programming environment like Django, Turbo Gears, or Zope, Python can easily do anything PHP can, but PHP is not even near to doing everything Python can do.

Re:why? (0)

Anonymous Coward | more than 3 years ago | (#31236848)

just like you said... where c is "really needed" it still must be used. whereas everything else php does in a much more flexible fashion. the flexibility is the root of all attacks on php because it allows morons to do things the wrong way if they choose. it also allows geniuses to implement procedural processes much more elegantly.

python is pointless.

Re:why? (1)

daver00 (1336845) | more than 3 years ago | (#31237454)

"...everything else php does in a much more flexible fashion...."

"...it also allows geniuses to implement procedural processes much more elegantly."

Let me guess, you are 15?

Re:why? (0)

Anonymous Coward | more than 3 years ago | (#31237774)

I am 7. And I will have your job when I am 15.

Re:why? (0)

Anonymous Coward | more than 4 years ago | (#31238492)

You've convinced me. The world only needs two programming languages, and by miraculous coincidence, those two just happen to be The Pair, and anything other than those two is totally superfluous.

There. That's what you wanted to hear, right?

Re:why? (0)

Anonymous Coward | more than 4 years ago | (#31238588)

well... if you're saying that python is good because it can use c libraries, but c is still required for some things, then that doesn't really matter... c can still use c libraries, and is better at doing it, and you can't not use c.

so "python is better because it's faster to code than c"... first off i don't believe that, but even if it were true, i can confidently say that it's faster to code in php than ANYTHING. if you don't need classes or types or constructor functions or static main voids you don't use them. you just alter the data you need to alter. nothing else. so if you want fast coding you have php.

if you think python is the answer, you are kidding yourself.

Monty (5, Funny)

ulski (1173329) | more than 3 years ago | (#31235976)

Woman: Well there's rat cake ... rat sorbet... rat pudding... or strawberry tart.
Man: Strawberry tart?!
Woman: Well it's got some rat in it.
Man: How much?
Woman: Three, rather a lot really.
Man: ... well, I'll have a slice without so much rat in it.

Why is there a rat on the cover of a snake book anyway? Perhaps O'Reilly already used a snake picture on the cover of some other book and they didn't wanted to confuse people by having 2 snake books?

Re:Monty (2, Insightful)

bsDaemon (87307) | more than 3 years ago | (#31236120)

IIRC, there is a python on the cover of 'Programming Python.' I don't know why they picked a mouse for this, maybe because it was less confusing than picking a second kind of snake? The cover of 'Programming Perl' is, famously, the camel, however the language isn't called camel, so when they put the llama, alpaca and vicuna on 'learning perl', 'intermediate perl', and 'mastering perl' respectively, it was obvious they were related but don't cause any clash due to naming. What does the sheep on 'Perl Cookbook' have to do with anything?

Re:Monty (2, Insightful)

Cryacin (657549) | more than 3 years ago | (#31236220)

What does the sheep on 'Perl Cookbook' have to do with anything?

Maybe mutton for dinner?!?

Re:Monty (1)

Savage-Rabbit (308260) | more than 3 years ago | (#31238386)

What does the sheep on 'Perl Cookbook' have to do with anything?

Maybe mutton for dinner?!

Well, in that case let's hope they don't put a rat on the cover of the Python cookbook...

Re:Monty (1)

geekmansworld (950281) | more than 3 years ago | (#31236640)

Honestly, I puzzled over this very cover at the bookstore yesterday whilst picking up my copy of "Active Directory for Dummies".

There are so many technologies that should lend themselves well to O'Reilly covers, yet don't (I also puzzled why the mySQL books didn't have dolphins on them).

But Python not having a python? Well that's just silly...

Re:Monty (1)

jra (5600) | more than 3 years ago | (#31236980)

FWIW: the colophons generally (I'm tempted to say always) explain the theory behind which a given animal was picked for a cover.

Re:Monty (1, Funny)

Anonymous Coward | more than 3 years ago | (#31236194)

A python would find a rat rather tasty.

Re:Monty (1)

thatpythonguy (1726724) | more than 4 years ago | (#31238636)

Why is there a rat on the cover of a snake book anyway? Perhaps O'Reilly already used a snake picture on the cover of some other book and they didn't wanted to confuse people by having 2 snake books?

Correct! O'Reily's Programming Python already has a snake! I suppose they decided to go with the snake's food.

Both of Alex Martelli's books are better IMHO (1)

Anonymous Coward | more than 3 years ago | (#31235994)

Python in a Nutshell and Python Cookbook. Both discuss that deployment stuff, for example. Neither of them is geared towards complete beginners to programming though. They are very good if you're experienced with some other language and have picked up the basics of Python from the online tutorial.

Learning Python is not a terrible book, but (except for the rather inconvenient matter of being about a pathological eclectic rubbish lister instead of being about Python) Learning Perl does a better job of accomplishing similar goals (explaining programming to non-programmers starting from scratch).

Re:Both of Alex Martelli's books are better IMHO (1)

roky99 (869500) | more than 3 years ago | (#31237048)

Python in a Nutshell ...

This would be a great book were it not for the fact that it has just about the worst index I have seen in a technical book, let alone a reference book!

I agree with you about Learning Perl vs. Learning Python. The former was a short, to the point, book that covered the basics, got me going with the language. From there I progressed to Programming Perl for the details, and the excellent Perl Cookbook for the how-to recipes. I have found the Python equivalents to be disappointing. I read an earlier edition of Learning Python but found it badly written and going into slightly bizarre amounts of detail at certain points but not explaining other things very well. I also have a newer edition that I picked up cheap but haven't read yet and it looks like it might be better but now seems to have got too big.

It's strange really, as Python is so much cleaner than Perl so one might have expected that to make it easier to write books about it.

Better Than First Edition? (4, Insightful)

adipocere (201135) | more than 3 years ago | (#31236018)

I sincerely hope that this version is better than the first edition, although anything short of a random re-arrangement of pages would serve as an improvement. The first edition actually delayed my initial use of Python by about a year and a half. I had heard wonderful things about the language so I figured, "Ah, an O'Reilly book!" Big mistake.

Endless bits about immutability, without hints as to why I ought to care. I can appreciate the use of the interactive prompt now, but to start with it seems ... strange. I was not transitioning to Python from shell programming, and I doubt many do. Lambda expressions, entirely too early. Not a great deal of attention paid to idiom, which is just about central to learning a new language. Little discussion of how you might have accomplished tasks in other languages and wish to do the Pythonic equivalent. I loathed the first edition and refer to it precisely never. I eventually dropped it in a puddle and felt no urgency towards retrieving it. The now-wrinkly cover suggests that some unhappy deity has attempted to purify it by flood.

I ought to have tried fire.

Re:Better Than First Edition? (1)

gpuk (712102) | more than 3 years ago | (#31236382)

If not this book, care to share an alternative recommendation or two?

Re:Better Than First Edition? (3, Informative)

kpainter (901021) | more than 3 years ago | (#31236764)

Programming in Python 3: A Complete Introduction to the Python Language by Mark Summerfield is better IMHO.

I gave up in the middle of Learning Python 3rd Ed. One of the things I absolutely hated about Learning Python is the author continually telling you about X will be covered later in chapter Y. There is a LOT of that. That and half-way through the book, I still couldn't do anything simple as he hadn't even talked about for loops yet. Too much detail on the finer points of data types and too little "quick start". I got bored with this book.

I don't doubt that there is a lot of great info in that book. It just isn't organized very well at all. My guess is the 4th ed. is changed to reflect Python 3.x. If it were reorganized, it would probably be really good.

Re:Better Than First Edition? (3, Insightful)

Monkey-Man2000 (603495) | more than 3 years ago | (#31236798)

If not this book, care to share an alternative recommendation or two?

Well, I can't disagree with the grandparent's very nice flame, but why not start with Guido's tutorial? http://docs.python.org/tutorial/ [python.org] Between that and the library reference, I was up and running making useful scripts in an afternoon at work one day, but I had previous programming experience. But since this book isn't for people like that, who is it for? Only people I can think of are language lawyers, and there's a free source for that as well! http://docs.python.org/reference/index.html [python.org]

Re:Better Than First Edition? (1)

Monkey-Man2000 (603495) | more than 3 years ago | (#31237036)

Actually, I should have also recommended the Python Cookbook even though it's quite old and you can probably pick it up in a bargain bin (http://oreilly.com/catalog/9780596001674). It's kind of nice for the quick and dirty examples if you also refer to the language reference and tutorial to understand what the authors are doing. I.e., it's not a very good introduction to the language alone.

But the best part is the strange looks you get from non-computer people when it's sitting on your shelf!

Re:Better Than First Edition? (1)

thetoadwarrior (1268702) | more than 3 years ago | (#31237874)

Python Essential Reference is quite good, imo.

Re:Better Than First Edition? (2, Informative)

slimjim8094 (941042) | more than 3 years ago | (#31236836)

I have probably the previous edition of this book, and what you're describing sounds like a different book. Lamda expressions came after basic and intermediate functions - I had no problem with it. All he talked about was idiom - the "pythonic" way of doing things - while mentioning that a C programmer would probably have used a loop instead of a map expression, etc.

So I'd say they fixed it up a bit.

Re:Better Than First Edition? (2, Interesting)

mindcorrosive (1524455) | more than 3 years ago | (#31236854)

Endless bits about immutability, without hints as to why I ought to care. I can appreciate the use of the interactive prompt now, but to start with it seems ... strange.

The thing about mutability in Python is that it can bite you in the neck if you assume the variable passing and assignment work as in some other popular languages. I can appreciate the author's tirades about this, as he brought his point around, even with simple examples. And how do you propose to start with a language that doesn't have one-IDE-to-rule-them-all, like Visual Studio or Eclipse? You know how sparse is IDLE by today's standards.

Little discussion of how you might have accomplished tasks in other languages and wish to do the Pythonic equivalent.

That's why there's this other book, "Programming Python", again by Lutz, where he discusses the practical aspects of Python programming, and using the standard library modules. There are examples of the "Pythonic" way to do this or that, instead of masking C/C++ syntax with Python expressions. The discussions of modules, packages and classes is extensive, and down to the details of how they work and are used.

I understand your frustration, and can't comment on the first edition that you've seen. I've preordered the fourth edition - this one - (the whole 1000 or so pages), and I found it a very good self-educational tool - I managed to learn most of the ins-and-outs of the language in just one week, without having prior exposure to Python (I've got experience with 3-4 other programming languages, admittedly). I'd recommend it highly for anyone that wants to learn Python (the language) quickly.

Of course, this is my opinion, so take it as you may.

Re:Better Than First Edition? (1)

tepples (727027) | more than 3 years ago | (#31237592)

The thing about mutability in Python is that it can bite you in the neck if you assume the variable passing and assignment work as in some other popular languages.

As I understand it, variable passing and assignment works in Python like it works in Java, or at least as it would if every variable in Java were of type java.lang.Object (with autoboxing of primitive types).

Re:Better Than First Edition? (1)

McNally (105243) | more than 3 years ago | (#31237164)

I'll chime in as another who found a previous edition of this work to be flawed -- enough so to tarnish the O'Reilly brand for me. While it's possible the newest edition is better it sounds (from the review) more like an update than a re-write.

Re:Better Than First Edition? (0)

Anonymous Coward | more than 3 years ago | (#31238138)

A whole brand tarnished on one product out of hundreds (if not thousands)?! You're harsh man!

The Bible? Bad Analogy... (2, Interesting)

happy_place (632005) | more than 3 years ago | (#31238328)

O'Reilly "Learning X" (fill in X with your programming language of choice) are not "BIBLE"s. They're learning texts. For the real meat of the language, decent reference and altogether comprehensive understanding of life and the universe, you'd want to pick up O'Reilly "Programming X" books. So in this case, Programming Python would be a Bible, a book you return to again and again. The Programming series of books, for most experienced programmers is generally just as good a place to start learning the language, and you don't need the Learning series.

Which Python? (1)

cephus (1471105) | more than 3 years ago | (#31236138)

Yes, but where is the chapter on how to do the dead parrot sketch?

easy to learn (0)

Anonymous Coward | more than 3 years ago | (#31236150)

i learned python - look - heres how you say hello:"sssssssss" and goodbye "ssssss". snake talk is easy.

Re:easy to learn (2, Funny)

MaskedSlacker (911878) | more than 3 years ago | (#31236552)

Then how come only Harry can do it?

First lesson (0)

Anonymous Coward | more than 3 years ago | (#31236154)

This is a space:
This is a tab:
Learn to recognize them, you'll be using a language where they're semantic.

Re:First lesson (0)

Anonymous Coward | more than 3 years ago | (#31236328)

And this was reason enough for me not to touch Python. One of my more trying problems arose from a Makefile that was whitespace sensitive. It worked with or without the correct whitespace, just in different ways.

Re:First lesson (0)

Anonymous Coward | more than 3 years ago | (#31237366)

Python uses whitespace in a very sensible way. Perhaps if you'd bothered touching it you'd know that by now.

Too wordy (4, Informative)

milgr (726027) | more than 3 years ago | (#31236564)

I bought this book about a month ago. I had my doubts about a book this size, and my doubts were realized.

I learned C from K&R first edition. K&R is about 150 pages (from memory). It covers all of the language succinctly and completely. Actually, it covers most of the language twice - first in tutorial form then in specification form. It is a fine resource.

Why should a book on Python be over 1000 pages? I started reading this book the same way I read K&R - from the beginning. Unlike K&R, after 50 pages I barely got to coding. Within each section the language is quite verbose. I suspect that the authors were paid by the word or the page.

On a positive note, I was able to use this book as a reference book as the index is quite reasonable.

I would recommend this book to those insomniacs who are interested in learning Python.

Re:Too wordy (1)

mirix (1649853) | more than 3 years ago | (#31236766)

The second K&R (with ANSI stuff added) Is close to 300 pages, IIRC.

Re:Too wordy (1)

jabuzz (182671) | more than 3 years ago | (#31237160)

The copy on my shelf says 272

Re:Too wordy (1)

fredjh (1602699) | more than 3 years ago | (#31236776)

It seems people have a great deal of problems documenting object oriented languages, IMO.

The C book is simple and straightforward because C is simple and straightforward by comparison; you don't get lists and dictionaries and so forth in C.

Re:Too wordy (1)

stm2 (141831) | more than 3 years ago | (#31237034)

Maybe it is because Python has a large standard library (so called batteries included).
Regarding paying per page, as a book author I can confirm that you are paid per page only if you accept to typeset the book (with LaTeX). That is a one time payment appart from royalties. If you don't typeset, you don't get paid by page, just have to follow the contract that says between xxx and xxx pages (where xxx are limits).

Re:Too wordy (0)

Anonymous Coward | more than 3 years ago | (#31237100)

I would argue that the Python language and standard libraries ("batteries included") are at least 10x as big as C's. Also, Python is object-oriented /and/ functional programming paradigms covered in addition to C's procedural. (Sure, you can shim OO into C with libraries (Gobject, e.g.), but it's sure as hell not covered in K&R.)

Missed out on Python (1)

physburn (1095481) | more than 3 years ago | (#31236618)

When learning languages i completely missed out on Python, i learn't perl and php, java and C and even Occam and Fortran. But no Python, are the any advantages to the snake named language?

---

Python Programming [feeddistiller.com] Feed @ Feed Distiller [feeddistiller.com]

Re:Missed out on Python (1)

Just Some Guy (3352) | more than 3 years ago | (#31236786)

When learning languages i completely missed out on Python, i learn't perl and php

...having skipped right past English.

Re:Missed out on Python (1)

maxume (22995) | more than 3 years ago | (#31237810)

He is advertizerating his feed thingamajob.

Re:Missed out on Python (4, Informative)

navyjeff (900138) | more than 3 years ago | (#31236948)

I found Python to be a useful language for scripting and accessing C libraries.

One of the things I like most about it (and others seem to hate) is that it's sensitive to whitespace. This feature has the side effect of making the language more readable and forcing people to indent their code. After programming in Perl, did you ever go back and try to figure out what you did a year ago? I find that my year-old Python programs to be much more readable than my year-old Perl.

Also, if you're a scientist or engineer, I recommend "Python Scripting for Computational Science". It will get you programming much earlier than Learning Python and is oriented toward mathematical calculation and visualization problems.

Re:Missed out on Python (0)

jabuzz (182671) | more than 3 years ago | (#31237286)

Yes because no matter what language I use I write readable code - PERIOD. Readable code has nothing whatsoever to do with the language. I can write unreadable Perl and write readable Perl. I can write readable Python and unreadable Python. Well I could if I new Python :-)

Re:Missed out on Python (1)

navyjeff (900138) | more than 3 years ago | (#31237708)

Except that in Perl (and other languages), it's incredibly easy to write unreadable code. With Python, not so much.

I've seen some code you've written, and I agree it's quite readable. You obviously spent some time keeping it clean and well-structured. One CAN always write readable code, but it is quite easy (and common) to use code kludges and make it hard to read in most languages. I've seen a few horrific Perl kludges, as well as a lot of improperly indented C, and ugly html. Maddening.

The difference in Python is that it requires indentation, and most of the language is quite plain. Conversely, obfuscated code is difficult to write in Python. Try it sometime.

Re:Missed out on Python (2, Informative)

Manhigh (148034) | more than 3 years ago | (#31237028)

While I cant speak to php or Occam...

You aren't forced into object orient programming as with Java, although the language does have good implementations (IMHO) of classes if you choose to utilize them. It also doesn't force the 'one class per file' structure of Java upon you. (Granted its been years since I've touched Java, so these critiques may no longer apply).

I started by using Python for a lot of the things for which I initially used Perl. I find Python code immensely more readable than Perl.

Lately I've used Python alot because it has some superb 3rd party libraries for scientific computing (numpy, scipy, matplotlib are the three which I use the most.) These libraries give Python the utility of Matlab (vectorized functions, easy plotting, interfacing to C and Fortran for speed) in an open platform without the fees associated with Matlab.

For my job (aerospace engineering) Python is now my go-to language when I first start working a problem, and I transition to C or Fortran only if I need the speed or someone else requires me to do so, which is not often these days.

Re:Missed out on Python (1)

selven (1556643) | more than 3 years ago | (#31238206)

You forgot the Python alternative to Mathematica [sagemath.org]

Re:Missed out on Python (0)

Anonymous Coward | more than 3 years ago | (#31237302)

When learning languages i completely missed out on Python, i learn't perl and php, java and C and even Occam and Fortran. But no Python, are the any advantages to the snake named language?

I just had a conversation with a guy I'm stuck working with on a project with. He was ready to consider using any language, as long as it was Python. It didn't seem to matter to him that it is totally unsuited for the task the client has in mind. Python isn't so much a language as it is a religion, kind of like Perl.

Re:Missed out on Python (0)

Anonymous Coward | more than 3 years ago | (#31237324)

Python is a fairly functional language, which is something you are missing in your repertoire. Lambdas and list comprehensions are very useful and interesting constructs that apply to certain kinds of problems a lot more readily than the declarative languages you might be used to, but they might require overcoming a learning curve. Python (and, similarly, Ruby) is a fairly shallow introduction to the otherwise fairly steep family of functional languages.

It is often abused as a simpler Fortran or C, since it is very easy to do, so I would stay clear of that and try to stick to resources that teach you the common Python idioms.

Re:Missed out on Python (1)

sqldr (838964) | more than 3 years ago | (#31238134)

Compared to C and C++, it's a different kettle of fish. If you're using C++ where you would normally use python, then you shouldn't be using C++. I guess the only crossover between the two is that python has some excellent libraries that allow you to get almost dirty with system functions, as well as things like opengl and audio libraries, so if you're tweaking filedescriptors or writing a game and don't need a compiled language, then I guess there is a little grey area. Incidentally, there's "weave" which allows you to embed c/c++ code into python and compile it on the fly, so you can get the best of both worlds in some cases.

Compared to perl, I spend far less time looking in the python manual than I do in the perl manual when I'm using the same scripting language for the same task. Compared to perl's "there's more than one way to do it" motto, python has the philosophy of "there should be at least one obvious way to do it".

With this in mind, you achieve the same tasks in a different manner. Perl's workhorse is its built-in regular expressions. Python has them, but you tend to use them as a last resort.. its splitting, joining, globbing and list comprehension features are more than sufficient for the same tasks, and look less like, well.. ~= /^[^(.*|)+?(xyzzy)/gS

It also has more of a tendency to push you towards functional logic or use of iterators rather than getting bogged down with if/then/else type stuff.

Finally (from me.. there's probably more, but I'll stop now :-)) it has proper classes with proper constructors, destructors, typed exception handling, inheritance, etc. without all of that "bless" nonsense. Yeah, you can do classes in perl, but it's so much hassle, people tend only to use it for libraries and bigger programs. You don't think twice about using a class in python where appropriate.

Compared to java, although the syntax is a world apart, the grammar is actually very similar, and feature-for-feature, the language behaves in similar ways, except of course that java is a compiled language.

As for fortran, I guess fortran is a bit specialised. Python has things like complex numbers, but they're worlds apart really.

It took me about a day to learn python, and about 3 weeks to get confident with perl. The python language and library is designed by a quite slow moving, but very careful committee. Python has equivalents to CPAN, but CPAN is like doing a recursive wget on freshmeat and seeing what you get. The core library in python is so good and geared towards its users that you rarely (certainly as a sysadmin) have to bring in 3rd party modules except for specialist environments.

And once your brain is fried from coding... (1)

sootman (158191) | more than 3 years ago | (#31236944)

... you can go here [youtube.com] and start learning the other Python.

"I came in here for an argument!"
"Oh, oh, I'm sorry, this is abuse."

You can see I've been studying. :-)

Pages? (1)

jschmitz (607083) | more than 3 years ago | (#31236956)

Is this edition 500+ pages too? the last one is like a boat anchor.............

Best book ever (for CS graduates) (1)

stm2 (141831) | more than 3 years ago | (#31237156)

I liked this book (at least first ed., the one I read).
This book made me love Python. But I found it too hard for my colleagues at work (most of them biologists who were never exposed to programming), so I decided to write my own book (tinyurl.com/biopython )
I think "Learning Python" is a must have for the seasoned programmer who wants to learn Python.

That's not quite the python bible. (0)

Anonymous Coward | more than 3 years ago | (#31237190)

This is [amazon.com] . Don't confuse people. Its also not the idiot's guide, for dummies.

I understand its a figure of speech, but its not a very good one and may confuse people with a different product.

Question: Who's making a living coding Python? (1)

gestalt_n_pepper (991155) | more than 3 years ago | (#31237458)

I mean, exclusively coding in Python? Who's got a paying job? Just curious.

Re:Question: Who's making a living coding Python? (1)

Ogi_UnixNut (916982) | more than 3 years ago | (#31237726)

I had a job doing python development for a media company. Mostly for internal/backend systems. Did it for years, but the recession resulted in my unemployment. I have since found 5 other jobs who want python dev's, so there seems to be demand, and demand seems to be increasing as time goes on.

Re:Question: Who's making a living coding Python? (1)

gestalt_n_pepper (991155) | more than 3 years ago | (#31238262)

Interesting. Was it ILM? I know they've used Python forever.

Re:Question: Who's making a living coding Python? (0)

Anonymous Coward | more than 3 years ago | (#31238324)

Me. I got the job as a graduate, got trained in Python and after using it quite some time you realise that what looks like a bit of a simple language really does have lot of depth. It's just a shame that most people who criticise it have never bothered really learning it.

I use other languages in my spare time (it doesn't seem like a good idea to become a one trick pony) but at work it's all about Python.

Re:Question: Who's making a living coding Python? (1)

An ominous Cow art (320322) | more than 4 years ago | (#31238532)

I am not exclusively coding in Python, but I do as much in it as I can. Probably about 80% Python and 20% Visual FoxPro, these days.

beautifully type-set book? (1)

larry bagina (561269) | more than 3 years ago | (#31237568)

I'm calling bull shit on that one.

Wear gloves. (3, Funny)

NeoSkandranon (515696) | more than 3 years ago | (#31237982)

Carpet pythons, like I own, are bitey bastards. I hope whatever python you learn about in this book is a little more friendly.

Load More Comments
Slashdot Login

Need an Account?

Forgot your password?