Beta

Slashdot: News for Nerds

×

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!

Beginning Python: From Novice to Professional

samzenpus posted more than 8 years ago | from the from-start-to-finish dept.

436

nazarijo writes "Python seems to be devouring everything these days, with more and more people using it for serious projects. It's quickly supplanting Perl in some circles, and with good reason. It's a powerful, richly featured language with boatloads of extensions. And, unlike Perl, it's very easy to do complicated things in simple, legible code. Python books are still only a small part of the shelf at your local bookstore when you compare it to the popularity of Perl, but which ones are the gems and which ones are fluff? Having looked at a lot of Python books in the past couple of years, I think that Beginning Python: From Novice to Professional is the one that I'll most recommend to people." Read on for the rest of Jose's review.

Beginning Python is loosely grouped into three main sections. The first deals with Python fundamentals, all the goodies that are inherent to the language and the modules that it ships with. It's surprising to see how rich the language is out of the box, especially when compared to some other scripting languages. The second section would be the chapters covering popular extensions for a variety of services. These include network and web programming, SQL objects, and even GUI programming. And finally the third section is a set of 10 projects in Python, which bring everything together in a concise fashion.

I like this book a lot because it is very clear in its delivery, both the prose and the code examples used, and is consistently Pythonic. The Python language lends itself to a powerful programming style and, unlike Perl, many Python developers I know don't bother with a dozen ways to perform a simple action, they get it done and move on. What you wind up with is clear code that's easily understood by someone new to the language.

Unlike what the title would suggest, Beginning Python isn't only for the first few weeks with the language. The book is large and in depth, and the coverage of material is fantastic in many ways. You get a quick tour of the basics and then you move on to an overview of the language and then its common features. The inclusion of the 10 projects is another benefit to the intermediate user. She can refer back to this book for additional information and pointers from time to time, it wont sit still on her shelf.

That said, there are a few things in the book that I tend to disagree with. For example, the author dissuades you from using destructors in your code, but in my experience they're far more reliable, and a better place to do some cleanup, than he states. A few chapters are also a bit skimpy when they didn't need to be. For example, Chapter 18, which covers packagers like the distutils component from Python, needed to be fleshed out a lot more. This is a powerful feature in Python and sound docs on it should just be there. There's no reason to hold back on something so vital. The section on profiling in Chapter 16 is also a bit thin around the middle when it needn't be. While this seems like a minor point, having a reference to speeding up code (and measuring the improvements) is always nice. And finally, Chapter 17, which covers extending Python, is simply too short for its own good. A more in depth example would have been appreciated.

I have begun recommending this book to people I know that are smart and program in other languages, but aren't very familiar with Python. Many beginners books only take a person so far before they become a useless item on the shelf. This means that he $30 or more that was spent is now gone, so I've grown to be observant of how long I expect a book to be useful. I anticipate the useful shelf life of Beginning Python will be longer than average for most general purpose programming books for a single language. What's more is that it's not a dry reference book. Couple this to a Python cookbook for recipes and you have a two volume "mastering Python" series.

If you've been curious to learn Python and haven't yet found the book that speaks to you clearly, this may be the one. I'm pleased with the quality of the writing, the examples, and the quick pace of the book. While it's nearly 30 chapters in length, most of them are short and focused, making them easily digestible and highly useful. Overall probably the best Python books I've had the good fortune of reading."


You can purchase Beginning Python: From Novice to Professional from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

cancel ×

436 comments

Python? (-1, Offtopic)

Anonymous Coward | more than 8 years ago | (#14447895)

O RLY?

Re:Python? (-1, Offtopic)

masklinn (823351) | more than 8 years ago | (#14447909)

YA RLY!

free python tutorial from book author (5, Informative)

chriss (26574) | more than 8 years ago | (#14447907)

Not only is this a good book, it is also one of only few that cover Python 2.4. The author Magnus Lie Hetland has a free python tutorial ("minimal crash course) (Instant python [hetland.org] ) on his homepage. He was also involved (as author, editor etc.) in several other book projects:

So we can assume he has a clue what he is writing about.

His homepage [hetland.org] uses PHP, btw.

Chriss

--
memomo.net - brush up your German, French, Spanish or Italian - online and free [memomo.net]

Re:free python tutorial from book author (3, Informative)

dmeranda (120061) | more than 8 years ago | (#14447964)

Python Cookbook, Edition 2 also covers version 2.4. And it is also a very useful book, even for those who know Python quite well...you can always learn a few new tricks.

http://www.oreilly.com/catalog/pythoncook2/ [oreilly.com]

being python (3, Funny)

joe 155 (937621) | more than 8 years ago | (#14447911)

we are the knights who say Ni!
Oh, sorry, wrong python

Re:being python (2, Informative)

masklinn (823351) | more than 8 years ago | (#14447925)

Not by far much, and Monthy Python based jokes are higly valued in Python the community and appreciated in python code/comments.

Re:being python (-1, Offtopic)

Anonymous Coward | more than 8 years ago | (#14448011)

From Novice to Professional? You too can be just like John Cleese when you're done with this book!

Re:being python (0, Offtopic)

kfg (145172) | more than 8 years ago | (#14448056)

Who wants a Python Full Monty anyway?

KFG

Damn perl bashing (0, Informative)

Anonymous Coward | more than 8 years ago | (#14447917)

Perl is as legible as the author makes it.

By the way, you have fun with that whitespace requirement.

Re:Damn perl bashing (4, Informative)

Metasquares (555685) | more than 8 years ago | (#14448090)

It is a bit harder to be legible in Perl than in other languages, to be fair, especially if you use regexps (but then, they're not all that legible anyway to begin with). Still, you get used to it after a while and it becomes as easy to read Perl as any other language.

Civilization IV is Python and XML (1, Interesting)

TheDoctorWho (858166) | more than 8 years ago | (#14447932)

'mazing ain't it?

Re:Civilization IV is Python and XML (2, Informative)

AuMatar (183847) | more than 8 years ago | (#14448042)

No it isn't. The AI scripts are. THe engine is C++.

Re:Civilization IV is Python and XML (4, Informative)

Zathrus (232140) | more than 8 years ago | (#14448235)

No it isn't. The engine and the AI are written in C++. All of the game scripts (map generation for example) and interface is in python, all the game data is in XML, and it's highly modable [civfanatics.com] .

The AI can be reprogrammed in C++ using their API. See Question 6 [slashdot.org] . I'm not positive that it's been released yet though.

Totally fresh in programming (4, Interesting)

Nichotin (794369) | more than 8 years ago | (#14447934)

I hope this is not modded off topic. Here goes:

I am probably not the smartest person in the world, and I have no programming experience what so ever. What I am looking for, is some easy language to either script or program. Would python provide a good starting environment? Have any of you been at my level, then learned python?
I have tried to do as much research as possible myself, but it seems that everyone I ask just woke up one morning, and found themselves to be able to program three or more languages (in other words, they do not remember how they started out). I have also tried to learn several languages by reading some O'Reilly books and similar, but I have been put off by the seemingly academic english that is used (my native language is norwegian, by the way).

If anyone have any recommendation, as tho where to start, I would be more than happy.

Re:Totally fresh in programming (2, Insightful)

LionKimbro (200000) | more than 8 years ago | (#14447983)

I have tried to do as much research as possible myself, but it seems that everyone I ask just woke up one morning, and found themselves to be able to program three or more languages (in other words, they do not remember how they started out).

Ha!

Insightful.

Yes, yes, true.

I skilled up when young, by typing in programs from the back of Family Computing.

I don't know what to tell "kids these days."

Entering computer programs, by hand, worked well for me.

Re:Totally fresh in programming (4, Informative)

Colonel Panic (15235) | more than 8 years ago | (#14447991)

I would check out How To Program [pragmaticprogrammer.com] by Chris Pine. It's very much for people who have no programming experience.

Also, for a very different, novel and fun approach you should check out Why's Poignant Guide to Ruby [poignantguide.net] . Did I mention it was fun? It's also a great intro for someone who has never programmed before.

I forgot to add (1)

Nichotin (794369) | more than 8 years ago | (#14447998)

Sorry, but I forgot to add the obvious part: Why do I want to program/script? In the first place, I would like to just create some gadgets, like my own ncurses gentoo installer or something (not too fancy, just for my own systems), or some simple webapp, like a poll (can be done with python server pages, right?). Other than that, tools for automating system tasks, perhaps.

Re:Totally fresh in programming (5, Informative)

Just Some Guy (3352) | more than 8 years ago | (#14448001)

What I am looking for, is some easy language to either script or program. Would python provide a good starting environment?

Absolutely! I think it's one of (if not the) best languages for new programmers. My main reasons are:

  • It has a very simple syntax.
  • The core language is relatively tiny - there aren't many keywords that you have to learn just to get started.
  • It is strongly, dynamically typed, which means that you can spend more effort on telling your program what to do rather than the nitpicky details of how to do it.

Opinions will vary, of course, but I think that Python is an excellent choice to start with.

Have any of you been at my level, then learned python?

Nope. When I was at your level, I had to learn a lot of really awful languages because the average person didn't have access to the nice ones. I would have loved having something so easy to learn and powerfully expressive at the same time.

Re:Totally fresh in programming (2, Informative)

JTorres176 (842422) | more than 8 years ago | (#14448010)

Python was the very first language I used to learn to program. I had multiple people telling me to start with python, so I perused over to their site, picked up a few online tutorials to go through, and started building a library of python books.

It helps because I can write one program for Linux, it works on my Windows PC with minor mods, and even works on my wife's Palm with similiar minor mods.

Python is a platform independant object-oriented programming language. It's great to learn, and it's great to start your learning with.

Re:Totally fresh in programming (1)

DaveInAZ (944478) | more than 8 years ago | (#14448081)

I'm not familiar with Python (which is why I was reading this) but, if you have to modify it, even a little, every time you port it to a new operating system, you can hardly call it "platform independent". The very definition of platform independence is that you don't have to modify the app.

Re:Totally fresh in programming (3, Insightful)

Just Some Guy (3352) | more than 8 years ago | (#14448131)

if you have to modify it, even a little, every time you port it to a new operating system, you can hardly call it "platform independent".

Out of curiosity, what other language qualifies as platform independent by your definition? Answer: there isn't one. In the context of what we currently have, today, in 2006, Python is just about as platform independent as anything else.

Re:Totally fresh in programming (1)

Budenny (888916) | more than 8 years ago | (#14448223)

Revolution.

Re:Totally fresh in programming (1)

Budenny (888916) | more than 8 years ago | (#14448436)

Should add, not free, but it has the most helpful mailing list there is. www.runrev.com

Re:Totally fresh in programming (1)

Cro Magnon (467622) | more than 8 years ago | (#14448238)

It also depends on the specific program. I have a small Perl program that runs as is on Linux, OSX, and XP. It's portable. But I also remember having to tweak another Perl program between Linux and FreeBSD. A very small tweak, but still a tweak.

Re:Totally fresh in programming (0, Flamebait)

DaveInAZ (944478) | more than 8 years ago | (#14448279)

Well, thank goodness you already know everything. Saves me the trouble of answering when you answer your own questions.

Re:Totally fresh in programming (5, Informative)

Jason Earl (1894) | more than 8 years ago | (#14448264)

For the most part Python software written on one platform will work just fine on any platform with Python installed. Python is completely portable in that manner, and official Python interpreters are available for a ridiculously wide array of platforms. However, if you don't take that portability into account when you start writing your software it is pretty easy to write bits that won't work when you move them to a platform with significant differences. For example, Python has APIs that deal intelligently with the various path separators, line endings, etc. that folks that write software for various platforms deal with every day. However, it's fairly easy to ignore these tools and do things like hardcode 'c:\MyDirectory\' into your application.

It is also possible to write Python software that uses third party Python extensions written in C or C++ that haven't been ported everywhere. Of course, this is possible in every "platform independent" language that I have heard of. It's certainly possible to do this with Java (witness IBM's SWT).

Re:Totally fresh in programming (1)

DaveInAZ (944478) | more than 8 years ago | (#14448400)

Wow! A genuinely intelligent response! I'm speechless. Fortunately, I'm not type-less. Thanks for the clarification.

Silly me. I was thinking that the point of using a platform independent language was to create platform independent apps. Where do I get such absurd ideas? I guess I was foolishly giving that other guy too much credit.

Re:Totally fresh in programming (1)

Syris (129850) | more than 8 years ago | (#14448284)

...and even works on my wife's Palm with similiar minor mods.

Python for the Palm? Last time I checked, the only package available was Pippy, a long unsupported port of Python 1.5 to the Palm OS. Is that what you're using?

A cursory google search did not turn up anything more recent.

Re:Totally fresh in programming (4, Informative)

Rei (128717) | more than 8 years ago | (#14448041)

Actually, yes, I would definitely recommend it. I started programming before Python (actually started in Basic because it was the only thing I had in 7th grade, then ran as quickly as I could away from it to a real language). However, python is a very easy language to learn and you don't need to deal with any advanced concepts to "make things work".

  * You don't have to declare variables
  * Code blocks are simply based on how you indent, making it always very legible
  * You can easily see what functions are available in a package using dir(), and you can get brief help information on a function by print function.__doc__, from within any python shell.
  * Very simple to do things that might take a long time to in lower-level languages - reading contents of files, splitting strings, performing regular expression matches, etc.
  * Performance is tolerable for most applications - just don't try to write Quake or physics calculation software in it.

Re:Totally fresh in programming (3, Insightful)

engagebot (941678) | more than 8 years ago | (#14448092)

Also interesting to note that many universities start students programming in C. The reason they do is because they want computer science students to get a good understand alot of what's going on in the background, not just learning a specific language.

The kicker: If you understand the principles behind it, you can easily learn any language.

You probably want to skip alot of the theory behind data structures and whatnot at the beginning though.

Re:Totally fresh in programming (4, Informative)

gabe824 (772563) | more than 8 years ago | (#14448093)

My first language was C, learned in a first year university introductory programming course, but when friends have asked me about learning programming I have recommended they start with python and the book How to Think Like a Computer Scientist: Learning with Python http://www.ibiblio.org/obp/thinkCSpy/ [ibiblio.org] . Its available free online. This is a good introductory book with no expectation of prior experience that teaches the ideas behind programming, not just the syntax of the language.

Re:Totally fresh in programming (2, Interesting)

T.i.m (149429) | more than 8 years ago | (#14448137)

Two years or so ago I made a CS master thesis where I tried to find / create the perfect language and IDE for learning to program. I did a pretty thoroug study of what is available and what is desired in such an environment. And i came to the conclusion that Python is very close to a perfect place to start learning programming.

I starred to make som tweas in the environment and the language but "Unfortunatley" I got a job right after I finished so I didn't have time to finish the projec. In case someone is interested, more information and a manhandle beta can be found at:

http://www.gahnstrom.se/tim/pystarter/ [gahnstrom.se]

Tim

Re:Totally fresh in programming (2, Insightful)

bcrowell (177657) | more than 8 years ago | (#14448253)

And i came to the conclusion that Python is very close to a perfect place to start learning programming.
I've used python as a language to teach people programming (in the context of a physics course, to do numerical simulations). It was OK, but the significance of whitespace was a major barrier for them to overcome. If I was doing it over again today, I'd probably use Lua, which has a very standard C-like syntax. Another consideration is that it might be good to use a language that's small enough to run in a web browser [hobix.com] .

Python's strengths, AFAICT, are its pure object-oriented design and the large set of libraries available for it. IMO, neither of these are particularly important for teaching beginners to program.

Re:Totally fresh in programming (2, Informative)

CoderBob (858156) | more than 8 years ago | (#14448210)

Like some have mentioned, Python is a great place to start learning. It's platform indpendent (point #1), object-oriented (point #2), and not VB or Java (points 3, 4, 5, 6, and 7.)

My hatred of Java and VB aside, however, I would add this: Once you get a good grasp of how to program in Python, it would be time to cut your teeth on a lower-level language. C or C++ would work here. It's going to be a little rough, as you get used to the different requirements, but you'll learn a lot more about Comp Sci.

Also, and this could possibly go before you learned C or C++, you may wish to take a look at design patterns once you get the basics down. Addison Wesley has an excellent book on patterns here [amazon.com] (No, there is no referer BS in the link) which I encourage you to look at.

Re:Totally fresh in programming (1, Insightful)

Anonymous Coward | more than 8 years ago | (#14448245)

My recommendation is pick up a beginners PHP* book. Start writing code it in as soon as you pick it up. Just as you read, write code. Once you've finished with that book, make 1 or 2 medium projects for yourself and try coding them until you feel fairly familiar with the language. Once you do that, pick up an intermediate or advanced php book and read that. Then go back to your code for the projects you did for yourself and rewrite it or write on top of it. You'll soon see how not only to write PHP, but also how to write rewritable code as well as maintable code. Rinse and repeat.

* You can replace PHP with any other language. Although I recommend PHP just because it's a fairly simple and widely used language.

Re:Totally fresh in programming (1)

RealProgrammer (723725) | more than 8 years ago | (#14448255)

I am probably not the smartest person in the world...

First lesson: yes, you are. If you want to be a programmer, that's how you will start. You're the smartest, but you just don't know everything.

What platform are you using? It makes a difference.

I learned to progam (well, if you call it that) using BASIC on a TRS-80 Model II (with the 16K expansion, thank you very much!). The cassette tape storage would lose half my saves, so my devotion to backups was burned in.

Just pick a language you can use on your own computer that has a "hello, world" program. That's what we call a simple program that just prints "Hello, world!" to your screen. Read the manual. Alter the program a little. Find other programs, and alter them a little. Eventually you'll get it.

You might try Javascript. There's not much barrier to entry, and you can run it anywhere you have a browser.

I found Python confusing at first, so I wouldn't recommend it to a raw beginner. Maybe for the second or third language.

If the syntax (all the little braces and symbols and how they go together) is confusing, you might try BASIC on a TRS-80 Model II :-).

Re:Totally fresh in programming (1)

Nichotin (794369) | more than 8 years ago | (#14448286)

My platform is mostly OS X and Linux, but I do have Windows available as well. I would like to start with something that works on at least two of these.

Err, my bad (1)

RealProgrammer (723725) | more than 8 years ago | (#14448367)

I just looked at Python. I must have been thinking of a different language, probably ruby or tcl.

Re:Totally fresh in programming (0)

Anonymous Coward | more than 8 years ago | (#14448293)

I find myself in a similar situation. I would like to learn a language and do a little programming. Not to start a holy war, but I looked at Free Pascal, and it looked interesting. However, Python seems to be the response I see when somebody asks about a good first language.

Re:Totally fresh in programming (1)

Bogtha (906264) | more than 8 years ago | (#14448301)

I am probably not the smartest person in the world, and I have no programming experience what so ever. What I am looking for, is some easy language to either script or program. Would python provide a good starting environment?

Absolutely. It's been used quite a bit for teaching purposes already, check out the Education special interest group [python.org] for more information.

Have any of you been at my level, then learned python?

You won't find many experienced programmers who started out with Python, simply because it's relatively new compared with languages like C and BASIC. Don't get me wrong, it's been around about fifteen years, so it's not some experimental system, but in relation to other languages, it's quite new.

I have also tried to learn several languages by reading some O'Reilly books

It really depends on the type of O'Reilly book you have. The 'Nutshell' books are aimed at programmers who want to pick up another language quickly, beginners should probably have one of the 'Learning' books.

Devouring? (5, Informative)

MosesJones (55544) | more than 8 years ago | (#14447945)

Python seems to be devouring everything these days... even replacing Perl

From Dice.com

Python : 545 matches
Perl: 3809
C#: 3850

Ummm over 1/8 of the demand of Perl or C#

Java: 11856

Java+BEA: 621

So Python is smaller than one specific application servers development requirements.

Python is better than Perl, but in terms of devouring? Its like saying that American Football is devouring other sports around the world.

Re:Devouring? (4, Insightful)

GigsVT (208848) | more than 8 years ago | (#14447989)

That's not a good measurement.

Those are unfilled jobs. Jobs that they couldn't find someone for without resorting to advertising. In other words, the jobs that get listed on job sites are the ones that no one wants.

Re:Devouring? (1)

blackmonday (607916) | more than 8 years ago | (#14448028)

I wouldn't use dice.com as a tool to measure Python usage.

Re:Devouring? (1, Insightful)

Anonymous Coward | more than 8 years ago | (#14448048)

It said devouring, not devoured ... meaning it is all
about dynamic grouth.
Do the same query one more time in a month and then
compare numbers. Ones that change faster are the ones
that deserve "devouring" attribyte.
Pretty sure, Python will be one of them

Re:Devouring? (0)

Anonymous Coward | more than 8 years ago | (#14448269)

No actually that is Nascar...

number one spectator sport in the world

On a related note... (2, Informative)

Just Some Guy (3352) | more than 8 years ago | (#14447947)

For a quicker introduction to the language, you might look at the article I wrote [freesoftwaremagazine.com] for Free Software Magazine [freesoftwaremagazine.com] . It's not an in-depth analysis by any means, but should get you acquainted with the basics in under 10 minutes.

It's licensed under the Creative Commons "Attribution-Share-alike" License, so feel free to pass it around if you want to.

Re:On a related note... (1)

d474 (695126) | more than 8 years ago | (#14448363)

Who the hell modded parent -Offtopic? There are like 30 posts above this one on this very topic, so why single this one out? Wasted Mod, dude.

MOD PARENT UP (0)

Anonymous Coward | more than 8 years ago | (#14448444)

There's a book that introduces Python. There's an article that introduces Python. How the fuck is a link to the latter offtopic in a story about the former?

Hmmm... (0, Offtopic)

somethingprolific (944769) | more than 8 years ago | (#14447948)

Why would we need better written programs? I hope this posts... IE crashed 3 times

Beginner, no programing experince! (0, Offtopic)

rkeenjr (832159) | more than 8 years ago | (#14447957)

Is this the book for someone like me? If not anybody have a suggestion? RKeenJr

Re:Beginner, no programing experince! (1)

Colonel Panic (15235) | more than 8 years ago | (#14448062)

How about How to Program [pragmaticprogrammer.com] by Chris Pine. I hear it's excellent for people who have no programming experience.

Another good (and fun) choice is Why's Poignant Guide to Ruby [poignantguide.net] . No other learning to program book has cartoon foxes.

Re:Beginner, no programing experince! (1)

rkeenjr (832159) | more than 8 years ago | (#14448122)

Saw that on your other post will purchase the First on in PDF tonight! Thanks for the insite!

Re:Beginner, no programing experince! (1)

Wisgary (799898) | more than 8 years ago | (#14448066)

When I was at borders yesterday I saw a book, I think it was from thompson that was for complete beginners with no previous programming experience. Lemme check to see if I can find a link... yes I found it, here's a link [amazon.com]

Before too many people post please read this! (2, Interesting)

Wisgary (799898) | more than 8 years ago | (#14447965)

I was at borders yesterday and I saw maybe 500 books from O'Reilly, 500 more from thompson and 1,000 more from random publishers, please for the love of god someone help me out and name me some *good* python books for an intermediate programmer. Most of my experience is in C++ and I would like to learn a high level language like Python, so please name me some books and help me in this impossible quest at borders.

Re:Before too many people post please read this! (3, Informative)

warewolfe (877477) | more than 8 years ago | (#14448257)

I've had good experiences with O'Reilly in general, and with "Learning *", "Programming *", and "* Cookbook", where * has been Python, Perl, PHP. However, have a look at http://python.oreilly.com/ [oreilly.com] and download the free chapters and source code before you buy. For an intermediate level programmer you can probably do without the "Learning Python" book. Good Luck.

Re:Before too many people post please read this! (1)

Wisgary (799898) | more than 8 years ago | (#14448292)

Oh I didn't know you could download chapters, that's awesome, I'll test a few and see what's good, thanks

Re:Before too many people post please read this! (1)

kfg (145172) | more than 8 years ago | (#14448274)

You might want to consider:

Beginning Python: From Novice to Professional

Just a thought.

Also check out the webpage Instant Python. Link in the first post along with links to books by the same author.

KFG

Re:Before too many people post please read this! (1)

Wisgary (799898) | more than 8 years ago | (#14448360)

Yeah yeah I know about the review book, duh, just wanted more input, and yeah I'll also check out that link. Thank you.

Re:Before too many people post please read this! (1)

kfg (145172) | more than 8 years ago | (#14448418)

Sorry for being a smartass . . . well, not really, it's what I do, but the fact of the matter is the review book and the first post actually are my input.

Didn't leave me much of any place to go but being a smartass.

KFG

Re:Before too many people post please read this! (1)

jcarter (726183) | more than 8 years ago | (#14448395)

Uh..

Well..

"Beginning Python: From Novice to Professional"?

I hear it's pretty good.

In case you have difficulty finding.. oh, I don't know.. a review of it, here's a link. Just click on it and scroll to the top:

CLICK ME

O, yeah? (3, Insightful)

Anonymous Coward | more than 8 years ago | (#14447975)

"And, unlike Perl, it's very easy to do complicated things in simple, legible code."

Perhaps it is time for you to get a perl book or take CS-101 course or something.

Re:O, yeah? (0)

Anonymous Coward | more than 8 years ago | (#14448121)

more likely, perl just behaves assininely and python just makes sense. I've been at my job over a year, and I'm forced to program in the attrocity that is perl.

Some things which don't work in the manner one might consider obvious...

spacing to allow for readability
my @my_array =
(
  (
    (a, b), (c, d)
  ), (
    (e, f), (g, h)
  )
); #is actually (a, b, c, d, e, f, g, h)

myfunction (@my_array, @my_array)

sub myfunction(@@)
{
    my (@a, @b) = @_; #most languages just let you do this in the prototype, but perl makes you type extra lines...
    #@a = (a, b, c, d, e, f, g, h, a, b, c, d, e, f, g, h)
    #@b = ()
}

#now lets assume for fun sake that, @my_array did initialize correctly. I call
#this "array splatter", as
#it's like dropping a soft object from a good height onto a solid surface...

my @second_array;
my @{$second_array[1]} = @{$my_array[1]}; # (a, b, c, d) is the result, not ((a, b), (c, d))

I'd even take sparc or x86 assembler of perl were it an option

Re:O, yeah? (0)

Anonymous Coward | more than 8 years ago | (#14448254)

No dude,

"my @my_array =
(
    (
        (a, b), (c, d)
    ), (
        (e, f), (g, h)
    )
); #is actually (a, b, c, d, e, f, g, h)"

is simply
@a = 'a'..'g';
But that is clearly not legible and requires a clue :)

Re:O, yeah? (1)

KDR_11k (778916) | more than 8 years ago | (#14448337)

Is a equivalent to 'a'?

Re:O, yeah? (0)

Anonymous Coward | more than 8 years ago | (#14448421)

the problem is, there's structure to that array. It shouldn't be equal to 'a'..'g'. But perl kills the structure.

and yeah, I forgot to quote my characters on this, but in the many pecies of code where I did stuff like this, the problem was for lack of coding, it was for lack of keeping array structures.

The day I never have to see Perl again... Oh, it will be a beutiful day.

Re:O, yeah? (4, Insightful)

Just Some Guy (3352) | more than 8 years ago | (#14448388)

"And, unlike Perl, it's very easy to do complicated things in simple, legible code."

Perhaps it is time for you to get a perl book or take CS-101 course or something.

I've got both. So, tell me: what's the syntax for returning multiple complex objects from a function in such a way that they don't have to be dereferenced by the calling code (that is, they can be used directly, just like you were returning a single scalar)?

Python example from the interactive shell:

>>> def foo():
. return {'one': 'ein', 'two': 'zwei'}, lambda x: x + 5, str
>>> a, b, c = foo()
>>> a['two']
'zwei'
>>> b(5)
10
>>> print c.__doc__
str(object) -> string

Return a nice string representation of the object.
If the argument is a string, the return value is the same object.

I'm not overly stupid, but doing something so relatively easy in Perl put me at my limits. I like Perl, and I've written many large programs in it, but I always had to fight against the syntax. Python got out of the way and let me concentrate on logic instead.

Has to bash on Perl (2, Insightful)

Anonymous Coward | more than 8 years ago | (#14448045)

And, unlike Perl, it's very easy to do complicated things in simple, legible code.

This must mean you aren't able to write legible Perl code. Perl has been making complicated things simple for more than a decade. If you don't know how to write clean code, then your Python will also suck.

Re:Has to bash on Perl (5, Insightful)

Myddrin (54596) | more than 8 years ago | (#14448202)

And, unlike Perl, it's very easy to do complicated things in simple, legible code.

This must mean you aren't able to write legible Perl code. Perl has been making complicated things simple for more than a decade. If you don't know how to write clean code, then your Python will also suck.

Not directed at the parent, but at the Perl-snipping in the original post....

<RANT>

I'm a professional python programmer, and I've been making my living at it for a number of years now. (It was my embracing of python that allowed me to transition to a 100% MS free workspace.) I started using it a project a few years ago, and it's just stuck for a number of reasons. (meta-classes, extensibility, etc.)

One thing that drives me buggy about some python evangelists, (and many evangelists, in general) is the need to bash anything that is not their favorite brand (be it Creative vs iPOD, Python vs (insert any language here). And so on. The fact of the matter is that Perl is a perfectly good language. I don't use it on a regular basis personally, but I've seen, read and understood a good deal of Perl code w/o a hassle. (yes, I've seen some scary code, but I've seen scary code in C++, Python, Java, etc., etc., etc.)

Sometimes we just have to admit that there are multiple good tools that we could use, but we have a personal (and possibly irrational) preference for one over the other. That's life as a human being (which I'm assuming at least 99% of the readers out there are. :) ). Just because some people use Perl, doesn't make my choice of python (of C++, my other "main" language) any less valid.

It's real life, not a multiple choice test -- there is no single "correct" answer.

</RANT>

Ok, I'm done... back to work.

Re:Has to bash on Perl (0)

Anonymous Coward | more than 8 years ago | (#14448291)

In my mind (though your post wasn't in reply to anything I said), it's not so much that I'm hardcore for any one language (though I tend to prefer C or PHP, and python does look good), of the 10 or so languages I know, Perl, I find is the easiest to write obscure code in, has some of the worst debugging messages (even with strict, warnings, and the one other that I can never remember, turned on), and it handles many things in a less than intuitive matter. I've had more than one case, where what should have been a simple same-type assignment, modified my data. And personally, in my mind, nothing is worse for readable code, than the reliance on $_, in all of it's invisible forms.

Re:Has to bash on Perl (1)

jtorkbob (885054) | more than 8 years ago | (#14448373)

Amen brother. Remember: A poor workman blames his tools, and a jaded programmer blames his predecessor's tools. Bad code transcends boundaries of language.

for my $cliche (@$cliche_library) {
    print "$cliche\n";
}

My 2 scents (1, Offtopic)

Cro Magnon (467622) | more than 8 years ago | (#14448086)

I'm a total n00b in Python, but I like what I see. I'm planning to rewrite a Perl program I have in Python.

My biggest gripe is that Python lacks a "use strict" to protect me from my own badd speling.

tr0lL (-1, Troll)

Anonymous Coward | more than 8 years ago | (#14448087)

ple4se moderate [goat.cx]

the obligatory Python vs Perl post (5, Funny)

hashmap (613482) | more than 8 years ago | (#14448104)

EXTERIOR: DAGOBAH--DAY

With Yoda strapped to his back, Luke climbs up one of the many thick vines that grow in the swamp until he reaches the Dagobah statistics lab. Panting heavily, he continues his exercises--grepping, installing new packages, logging in as root, and writing replacements for two-year-old shell scripts in Python.

YODA: Code! Yes. A programmer's strength flows from code maintainability. But beware of Perl. Terse syntax... more than one way to do it... default variables. The dark side of code maintainability are they. Easily they flow, quick to join you when code you write. If once you start down the dark path, forever will it dominate your destiny, consume you it will.

LUKE: Is Perl better than Python?

YODA: No... no... no. Quicker, easier, more seductive.

LUKE: But how will I know why Python is better than Perl?

YODA: You will know. When your code you try to read six months from now.

Re:the obligatory Python vs Perl post (1)

Randolpho (628485) | more than 8 years ago | (#14448305)

After setting Yoda down, look looks around apprehensively.

LUKE: I feel cold.... death......

YODA: That file is strong with the dark side. A domain of perl it is. In you must go.

Re:the obligatory Python vs Perl post (1)

rkeenjr (832159) | more than 8 years ago | (#14448320)

Thanks I needed a laugh!

Simple, Legible Code (5, Insightful)

AthenianGadfly (798721) | more than 8 years ago | (#14448108)

And, unlike Perl, it's very easy to do complicated things in simple, legible code

The issue with Perl isn't that it's particularly hard to do complicated things with simple, legible code (not more so than a lot of other languages, anyway), but that it's very, very easy to do something extremely quickly, which often - but not always - means code that makes sense at the time but isn't necessarily readable, or leads to overly terse code. Yes, Perl makes it easy to do things wrong (and a lot of people out there do use Perl to make unreadable programs), but that doesn't mean that it can't be used to do things correctly as well as any other language.

Re:Simple, Legible Code (2, Interesting)

lawpoop (604919) | more than 8 years ago | (#14448427)

In Perl, it is easy to make legible code, and it is easy to make illegible code.

In Python, it is easy to make legible code, but it is difficult to make illegible code.

I would argue that this fact makes it harder to write legible code in perl than in python.

Dive into Python (4, Informative)

Jazzer_Techie (800432) | more than 8 years ago | (#14448110)

No discussion of Python literature can be complete without mentioning Mark Pilgrim's Dive into Python [diveintopython.org] , which is an excellent way to get to know the Python language. It's free for download in a variety of formats. Two caveats however, being that 1) it hasn't been updated in about a year and a half and 2) it assumes that you already have a pretty good grasp of programming in some other language. But if you've you got some coding experience and want to take a serious look at what Python has to offer, this is a great book full of nice examples (with the code available for download as well).

python regexes (2, Insightful)

funkelectric (931604) | more than 8 years ago | (#14448111)

After hacking perl for over 10 years, Python sounds very good. The first program I tried to write in Python was the quick-and-dirty thing I need most: Read a file and parse it using regexes. Perhaps I stumbled upon the one area where Perl shines in comparison with Python, for that is the impression I got. The Python regex methods do not seem a natural fit for the problem.

Python is very tasty (1)

digitaldc (879047) | more than 8 years ago | (#14448125)

"While it's nearly 30 chapters in length, most of them are short and focused, making them easily digestible and highly useful."

It also goes well with a cup of Java, fried Kalamaris and a side of Perl pasta.

Troll (0)

Anonymous Coward | more than 8 years ago | (#14448153)

Troll: And, unlike Perl, it's very easy to do complicated things in simple, legible code.

That is nothing but a troll and everyone who has actually used perl knows it. You can write illegible code in any language. You can write legible code in any language (except joke languages like Whitespace and BrinF*ck).

Eat Me (-1, Offtopic)

Anonymous Coward | more than 8 years ago | (#14448168)

Python would literally Eat Me !!

Python? Why not Ruby (on Rails)? Because ... (5, Informative)

chriss (26574) | more than 8 years ago | (#14448170)

Since this is inevitable to pop up, a very simplyfied version (slightly offtopic):

Why not ditch Python and use Ruby (on Rails)?

  • Ruby is a nice language. It looks more like Java (or C or Perl) than Python, so that may be an advantage for those who dislike Pythons whitespace handling (I think it is genius)
  • Rails is a very nice framework for developing database driven web-apps very fast
  • Someone (David Heinemeier Hansson) really cared to make this user/developer friendly. There is good marketing, nice screencasts (although basically smoke and mirrors), good documentation, a well structured central web site, lots of support. All this may be even more important than the technical differences to other platforms like Python.
  • It's hype, so you could easily sell it to management

Why better stick with Python?

  • Most of the hyped features Rails are available on Python too, although not yet in such a nice package. The Turbogears [turbogears.org] folks try this, but in a more pythoniac way. I like it better, since they actually bundled already established products like CherryPy and SQLObject instead of simply writing from scratch. This may not result in a smooth package like RoR, but it is more clearly aimed at the integration of other products.
  • There are tons of modules and documentation for Python out there. So if you come to the point where you want to include other features than those already present in your framework, it will be easier to add them from different sources, because a) there are more and b) integration is a more established process.
  • There has been a lot going on in the RoR aftershock to improve the situation, like discussions about merging the different frameworks (Turbogears/Subway) to create a unified and very powerful platform.
  • There is always a way up in Python with Zope (although this is a beast and documentation is bad, 3.X is much better, but lots of products currently still require 2.X) and integration in J2EE.
  • Python is old. There has not only been one generation of developers whos projects failed, but many. RoR is still in the "early adaptors" phase, where everyone sees the revolution and casualties are accepted. Ruby alone has had a strong following in Japan, but for the rest of the world Rails was the first contact. Wait a year until the "RoR sucks" postings appear, than you'll be much wiser.

Chriss

--
memomo.net - brush up your German, French, Spanish or Italian - online and free [memomo.net]

python isn't just for web apps (2, Insightful)

jbellis (142590) | more than 8 years ago | (#14448330)

For various reasons (more mature stdandard & third party libraries; English docs; real threading support -- this is a big one; etc) Python is a much better general-purpose language than Ruby.

(It's also about twice as fast, but honestly if Ruby is too slow for your project a factor of 2 probably isn't going to save you. Still, speed is a nice bonus.)

I have to wonder about this (1)

Timesprout (579035) | more than 8 years ago | (#14448262)

I like to play with Python occasionally but when I see something like

hat said, there are a few things in the book that I tend to disagree with. For example, the author dissuades you from using destructors in your code, but in my experience they're far more reliable, and a better place to do some cleanup, than he states.

I really have to wonder. Does someone have no idea what they are talking about or does a certain language have a very crappy garbage collector.

Anyone care to offer some insights as to why the reviewer made this statement?

GC and Destructors are Different Things (0)

Anonymous Coward | more than 8 years ago | (#14448390)

I don't know too much about python, but in general destructors and garbage collectors are not competing features.
A destructor can do some clean-up at the end of the objects life that is not necessarily memory related, like for a file object it could close the file.
The destructor will usually be called by the garbage collector, when an object is deleted or goes out of scope in a language like C++.

Re:I have to wonder about this (1)

Golthur (754920) | more than 8 years ago | (#14448399)

I'd probably say that it's because Python is both reference-counted and garbage-collected.

That is, it tracks reference counts for objects and calls __del__ when the last reference to the object goes away. If you don't create object reference cycles in your code, using __del__ for cleanup works great, but if you do, you then have to wait for the next run of the garbage collector to clean up the "lost" objects. The catch is that the garbage collector doesn't automatically reclaim the objects if you have a __del__ method - you have to manually determine the order to reclaim the objects in the cycle using the gc module (see here [python.org] for more pedantic details).

Perl vs. Python (0, Redundant)

Randolpho (628485) | more than 8 years ago | (#14448263)

Perl vs. Python flame war commencing in 5...... 4....... 3....... 2....... 1......

Python just hasn't been the same.... (0, Offtopic)

rayhigh (912376) | more than 8 years ago | (#14448273)

...since Graham Chapman died. Thank you very much, I'll be here all week....

Re:Python just hasn't been the same.... (0, Offtopic)

east coast (590680) | more than 8 years ago | (#14448435)

Man, slashdot is getting rough when even a Python joke gets modded down...

No programming experience? Here's what you need. (0)

Anonymous Coward | more than 8 years ago | (#14448314)

bembry.org/technology/python/index.php

Bryce Embry has written a set of Python tutorials well suited to first time programmers. I think it was written for high school students.

The trouble with trying to learn anything is the amount of 'noise' you have to filter out. You don't need 90% of what is in the man page. Most of the time, you need a minimum implementation that isn't obvious when you try to follow the documentation. Maybe that's why the dummies books are so successful.

Anyway, if you've never programmed before, this is the web site to see.

Dive Into Python? (1)

bblazer (757395) | more than 8 years ago | (#14448326)

What about Dive Into Python by Mark Pilgrim? Like the title says, you dive right in. There is no "Hello World!" stuff to mung through. He uses real world examples right from the start, and explains them in a way that a 4 year old could understand.

Learning Python (2, Informative)

kevin_conaway (585204) | more than 8 years ago | (#14448327)

I am a Java programmer by profession but I wanted to give Python a shot because it seemed like fun.

As a programmer experienced with OO programming and some other types of "scripting" languages, all I needed to read was Learning Python [oreilly.com] from O'Reilly. Great book, great language.

On a shameless side note, if you're a Scrabble fan, come check out my online, multiplayer Scrabble program written in Python. PyScrabble [sf.net]

A few good and free Python books (3, Informative)

YA_Python_dev (885173) | more than 8 years ago | (#14448344)

On the python.org [python.org] site you can find a big list of Python books [python.org] .

I suggest:

Good reading.

most helpful book (2, Insightful)

engagebot (941678) | more than 8 years ago | (#14448346)

I think the book thats most helpful to the novice programmer wouldn't be a book about any language at all.

It'd be a book about programming and algorithms in general. Its MUCH easier to root around in a 'hello world' program or the like if you understand things like loops, if/then/else statments, function calls, etc. Even the fundamental idea of declaring and using a variable.

-1 Troll for Submitter (2, Insightful)

toupsie (88295) | more than 8 years ago | (#14448393)

And, unlike Perl, it's very easy to do complicated things in simple, legible code.

So can Perl.

Python is for architects - Perl is for lumberjacks (2, Insightful)

mrfoos (584110) | more than 8 years ago | (#14448396)

Comparing to two for me is like comparing tree cutting with building houses.

When you build a house you need an architect and specific design rules so other people in the project can do their part. It takes a long time to build it, and someone has to live in the house a long time.

When you cut down a tree you're only interested in the fastest way possible to get it down safely. Who cares if it's pretty. If you didn't like the way the first one fell, you can make adjustments on the next.

A house builder wouldn't tell a woodcutter which axe to use. He doesn't care. Of course, woodcutters have no business building houses.

Personally? I like being a lumberjack. Nothing like fervorishly hacking away and yelling "TIMBER!" from a safe distance.

Python looks like a mess to me (1)

KDR_11k (778916) | more than 8 years ago | (#14448431)

Maybe I just missed the appropriate packages but to my knowledge Python lacks things like strict typing that are invaluable helpers when you want to make sure stuff works as it should. Nothing is more annoying than reading "int has no member function ______" and having to track down where that variable got its int contents from. After being introduced to Haskell in university strict typing just becomes something I really want in a language. There's just no real way to be sure all variables are the type you want when you're bug hunting and lack of access control for classes and their free extendability (being able to just add members to any instance of the class) are enemies of debuggable code as well.

Pattern matching would be nice too but probably not feasible.

Python inferiority complex? (1)

WampagingWabbits (627551) | more than 8 years ago | (#14448441)

Do I detect a trace of defensiveness in your tone? That you would like to think Python is gaining ground on Perl but you suspect it might not be? And you are confused as to why this is? Why don't Perl programmers leave their language in droves and convert to your favourite one? Why are slashdot, amazon, citysearch, ticketmaster, et al still using perl on their sites instead of Python for example?

It could be that you misjudge Perl. Like judging a book by its cover, you have failed to see that Perl is perfectly capable of performing powerful tasks with simple, clean, easily maintained code. Perl is a practical language, and while dollar and percentage signs (and brackets) might not win a code beauty contest they provide useful information none the less.

Perhaps while promoting Python's discipline over Perl's freedom of expression you have hit upon the reason for Python's failure?

I tried python (1)

plopez (54068) | more than 8 years ago | (#14448443)

But I found it too constrictive.

Right now Ruby is my new Perl.
Load More Comments
Slashdot Account

Need an Account?

Forgot your password?

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>
Create a Slashdot Account

Loading...