Beginning Python: From Novice to Professional
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: From Novice to Professional
author
Magnus Lie Hetland
pages
604
publisher
Apress
rating
8/10
reviewer
Jose Nazario
ISBN
159059519X
summary
Tour the Python language, from basics to advanced modules
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.
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.
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) 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 uses PHP, btw.
Chriss
--
memomo.net - brush up your German, French, Spanish or Italian - online and free
memomo: free web based language trainer DE-EN-ES-FR-IT
we are the knights who say Ni!
Oh, sorry, wrong python
*''I can't believe it's not a hyperlink.''
Perl is as legible as the author makes it.
By the way, you have fun with that whitespace requirement.
'mazing ain't it?
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.
Dvorak on Doomtech
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.
An Eye for an Eye will make the whole world blind - Gandhi
It's licensed under the Creative Commons "Attribution-Share-alike" License, so feel free to pass it around if you want to.
Dewey, what part of this looks like authorities should be involved?
Why would we need better written programs? I hope this posts... IE crashed 3 times
Is this the book for someone like me? If not anybody have a suggestion? RKeenJr
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.
"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.
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.
Dvorak on Doomtech
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.
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.
Slow down, cowboy! It has been 4 hours since you last posted. You must wait another few hours.
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.
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.
No discussion of Python literature can be complete without mentioning Mark Pilgrim's Dive into Python, 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).
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.
"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.
He who knows best knows how little he knows. - Thomas Jefferson
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).
Since this is inevitable to pop up, a very simplyfied version (slightly offtopic):
Why not ditch Python and use Ruby (on Rails)?
Why better stick with Python?
Chriss
--
memomo.net - brush up your German, French, Spanish or Italian - online and free
memomo: free web based language trainer DE-EN-ES-FR-IT
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?
Do not try to read the dupe, thats impossible. Instead, only try to realize the truth
What truth?
There is no dupe
Perl vs. Python flame war commencing in 5...... 4....... 3....... 2....... 1......
"Times have not become more violent. They have just become more televised."
-Marilyn Manson
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.
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.
My
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 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
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 suggest:
Good reading.
There's a hidden treasure in Python 3.x: __prepare__()
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.
Han shot first.
I just looked at Python. I must have been thinking of a different language, probably ruby or tcl.
sigs, as if you care.
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++.
So can Perl.
Strange women lying in ponds distributing swords is no basis for a system of government.
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.
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.
Justice is the sheep getting arrested while an impartial judge declares the vote void.
Man, slashdot is getting rough when even a Python joke gets modded down...
Dedicated Cthulhu Cultist since 4523 BC.
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?
But I found it too constrictive.
Right now Ruby is my new Perl.
putting the 'B' in LGBTQ+
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?
I've just started trying to learn how to program again and I've decided to give Python a go.
They REALLY need to clean up the Global Module Index though. I've mostly learnt the syntax and I've tried to move onto the meatier module parts but the module functions just lack too much information.
The function parameters are barely detailed. I have no idea if the parameters require a particular object type, or a string (or the string's particular format). Exceptions are barely documented either and I have no idea what exceptions are going to be propagated by a function that I am about to use.
He writes the Python is "quickly supplanting Perl in some circles." That's an intriguing statement. But instead of explaining how great Python is in concrete terms (in either summary or review), Mr. Nazario seems content to simply rip on Perl with flamebait like
unlike Perl, it's very easy to do complicated things in simple, legible code 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
This could leave a lot of people with the conclusion that Python mainly appeals to people with a chip on their shoulder about Perl, which does not serve the Python community well -- particularly when there are languages like Ruby that have evolved demonstrably superior ways of getting things done (compared to frameworks available for Perl OR Python).
"Unlike Perl" -- why are they so defensive? If Perl loses, it'll go the way of FORTRAN into the museum. If Perl wins, there's still plenty of room for other programming languages. Perl hasn't exactly made REXX, Pike, PHP, LISP, etc extinct or anything. (Not trolling, but I think Python users are so defensive because Python is the first language I know of since COBOL to make the whitespace of indention a significant part of the syntax.)
http://www.objectsbydesign.com/projects/python_uml .html
"CP4E? This new acronym stands for Computer Programming for Everybody, a new initiative by the creator of the Python language, Guido van Rossum. The proposal for CP4E was submitted in July, 1999 to the Corporation for National Research Initiatives (CNRI). CP4E has set as its primary goals the creation of a training curriculum and advanced, easy-to-use development tools to be used to teach the Python language to millions of non-technical computer users. Why?
"If we are successful, non-experts will be able use their computers and other intelligent devices much more effectively, reducing their level of frustration and increasing their productivity and work satisfaction."
The Python language has already won acclaim as one of the most elegant and powerful, object-oriented programming languages in use today. Python is open source and freely available for a wide number of platforms and programming environments. Many highly scalable applications have been implemented with Python on these platforms. See our Python Link Collection for links to Python resources and to get an idea of the range of Python's deployment.
It is our belief that UML, a widely adopted, standard notation for designing object-oriented software, could play a key role in the CP4E initiative and with Python development in general, as we will proceed to explain."
Think about it. Prodigious use of WHITEspace. Led by a guy named Guido. Even the language name is a both a Biblical reference and phallic symbol. COME ON!
Nicely done. A very well written introduction.
Don't forget make!
how to invest, a novice's guide
I used to fiddle around in the win 3.x area when i was (6-10) with qbasic copy-pasting
those speaker sounds and alternating things in that and later alternating gorillas.bas
I remember those days took me a lot of time to get brother jackob, frère jacques, broeder jacob to play on my pc speaker
because we in belgium use the do-re-mi music scale instead of the C,D,...
But that's beside the point i'm just pointing out although i had extensive experience when i was young with basic
i left it on the kitchentable when win95/98 came out and truthfully i lost a lot of skill.
Tried VB when i was 14 made some stupid programs to measure mathematical things of cubes, triangles,
But the most fun and the biggest learning experience i had
was when i tangled around with source: most things i learned was with gorillas.bas or the simple 2 player shoot game(vb)
Now i'm actively making a lot of shell scripts and i'm very happy with that.
The reason imho that i'm happy with it is probably because in a sense its programming and
i use that shell daily, it doesn't see the kitchen at all so to speak.
I want to program, you want to program but it takes time, effort and u can't let it stand on the table!
for that and other reasons i think the best way is to: start shell scripting and then evolve to python and later c/c++
i'm trying python and
i'm very happy with it but it's my next on my very big todo-list there still are some things i need
to learn in bash
A huge advantage bash, any scripting language, python, basic have in common is that it can/must (be) interpreted
so u don't have to compile and wait!
it's almost instant trial and error and that helps the beginning programming experience as you can tangle with source and see the results very rapidly
Or, as the following modern Zen poem has it:
To follow the path:
i got this from this site which is probably an interesting read for you
http://www.catb.org/~esr/faqs/hacker-howto.html
Anyway good luck
Wrox has great books, including Beginning Python.
Per Aspera Ad Astra.
this one.
Since the start of the review is basically a flame against Perl, I can't resist making a plug for it--especially since it was the first serious programming language that I learned.
." On reading it, I knew this was for me. So, eventually I found out I had to download Perl, which I did, and then I started going through the tutorial. URL: http://www.sthomas.net/oldpages/roberts-perl-tutor ial.htm
If a programming language is sufficiently powerful, you won't become proficient in it overnight. For myself, I went through three stages: tutorial, hobby, profession.
It started with me back in 1999 when I wanted to learn HTML, and so I set out to learn it. But in the mean time, a friend of mine in the business told me that with Perl you could pretty much do anything you want in making web applications. At the time, I didn't know the difference between server-side and client-side scripting, and I figured, why not give it a try?
So I searched on the internet and found Robert's Perl Tutorial. The introduction says, "It assumes that the reader knows nothing of programming whatsoever. .
Going through the tutorial took me two or three weeks. After finishing it, I decided to try to make my nascient website cooler than it was by adding some server-side scripting. Now that I wasn't just in the tutorial anymore, I had to learn something about CGI. That's when I found the site "CGI Programming 101", http://www.cgi101.com/class/ (I'm pleased it is still around, too.) From this I learned the rudiments of CGI programming with Perl.
From this, I wrote a program called Article Master, which, had I stuck with developing it, could have been *the* killer-app blogging software instead of MovableType. (I'm sure there are probably 50,000 other geeks out there who also started out with something like this, discontinued development on it, and are still kicking themselves in the butt for missing out on coming out with the killer app.) In any case, after building the software and getting it to work kind of OK, I developed a deployment package for it and submitted it to an online Perl script archive. After submitting it, the archive gave me a free email address and access to the exclusive programming forums. The site sent me an email telling me I got these exclusive benefits because I was a programmer.
I had never thought of myself as a programmer, but here was a site brimming with programmers telling me I was one of them. It was such a positive boost for me that it encouraged me further to develop my skills.
Soon enough, I bought the Perl CD Bookshelf from O'Reily. Now, I had all the information and reference material I needed to write almost anything I wanted. I did some other personal online projects, and then, somehow I got the idea to try out getting a job using Perl. (This was at the beginning of 2000, just before the dot-com bust, so the entrance bar was set pretty low.) I called up a head-hunting agency and asked them if they needed someone who knew Perl. The agent on the other side said, "Get down here ASAP!" I went, I took their computerized test, and the results made him do backflips. (Hey, I knew what JAPH meant, and that was a question on the test!) He said he would have no problem getting me into a job, which he did. (And the money was more than I had ever dreamed of making.)
When I started, I got an assignment (all CGI development) from one of the other lead programmers, and he asked me how long the job might take me. I hesitated, and just before I was about to say "a few days", he asked if I could do this in a few hours. I said, "Yeah, OK." I asked him if there was an HTML tool they used, and I just got this blank stare. I learned quickly that real Perl programmers don't use HTML editors--like our Perl code, we type everything else by hand. I somehow rose to the occaision and got the job done in time. From t
As if python itself wasn't fun enough :)
This sig is intentionally left blank
unlike Perl, it's very easy to do complicated things in simple, legible code.
Not willing to start some useless python vs perl comparizon, your assertion is wrong: in perl, it is also easy to do complicated things in simple legible code. As someone who write and read perl code on a daily basis for about 5 years, I have the feeling that you should have written: "with perl, it is very easy to do complex things in obfuscated write-only code".
I'd suggest an Obfuscated Python contest like the IOCCC, but I assume most Python coders actually have more important s--t to do.
Lumberjacks rule! When your tree falls upon and destroys a newly rehomed family's dwelling you can laugh at the accomplished architect maliciously, lunge at him with your axe and whip off his limbs...but watchit he'll bite your legs off
This is also the case of Fortran77 which is probably newer than cobol, leftovers from the punchcards. Even with the latest fortran compilers from intel works best with old fortan77 code compared to porting it to fortran90 or fortran95. maybe because it lack most of the features in modern languages. Not even a function stack (recursion impossible). * C Hello World in Fortran 77 C (lines must be 6 characters indented) * PROGRAM HELLO WRITE(UNIT=*, FMT=*) 'Hello World' END
Objects!
Perl == horrible bolted-on afterthought OO
Python == *much* better (real objects, finally!)
Ruby == pure heaven, everything is an object and iterable by default.
I was bored one day at home and recreated a class in ruby that I wrote at work in perl. Took me all day to do something in perl that it took about 1/2 an hour to do in ruby, and I added a couple of features as well. I also spent way more time looking up how to do stuff in perl that in ruby, event though I've programmed off and on in perl for years (a decade, in fact)....
If only "common" sense was actually that common...
Save yourself $15.30 by buying the book here: Beginning Python: From Novice to Professional. And if you use the "secret" A9.com discount, you can save an extra 1.57%!
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.
That's because Perl is versatile, flexible. Python forces you to do things The Python Way(tm). I've tried Python a couple of times, and I keep going back to Perl. Maybe I'm just a rebel, but I don't like a language telling *me* what to do (queue "In Soviet Russia..." joke here).
And, yes, I mostly just hate the whitespace-as-blocking braindamage. It's like Guido loved LISP, but hated the braces, so he re-invented LISP, poorly. But that's why I love programming-- everybody gets to choose their favorite poison.
Microsoft is to software what Budweiser is to beer.
Quoting "Handling indentation as code blocks" as a reason for why Python is better than any other language is not right. A good programmer will always indent his code doesnt matter which programming language he uses.
Clearly, Google is the next Microsoft.
So a couple months ago I got really into python. I've programmed in both C++, a bit of perl, and LISP (as well as a hodgepodge of other languages) and was really attracted to the powerful combination of functional tools and object oriented design. I found generators, iterators and other advanced language features absolutely great and started to really like the language.
As I got a bit more into the language I started finding myself continually frustrated. Despite the "we're all adults" attitude about privacy and object protection it seemed Guido (guy in charge of python language) repeatedly made deciscions telling me that I shouldn't use features like co-routines, continuations or other powerful features except in limited circumstances (generators). I've even heard rumors about removing map (or was it apply) from the language. It wasn't that these features couldn't be implemented (stackless python did it) or they wouldn't be usefull (see ruby's use of coroutines) but as best I could tell Guido didn't like these functional or otherwise non-sequential features. Overall this lack of general functionality just made the language feel sorta unfinished and frustrating.
I've moved on to ruby since then which, while underneath is pretty different, seems to give me all the features of python plus those general features like co-routines and continuations.
Anyway this post might be a little off topic but I was wondering if there was any valid reason not to involve these powerfull features other than just personal taste. I can understand if some programmers coming from a procedural background might find these features confusing or harm code readability but is there any other reason? I love these sort of additions and I just can't figure out why, despite clear interest (stackless python, several PEPs) they aren't included in python to make it feel 'complete'.
If you liked this thought maybe you would find my blog nice too:
. . . but if you are serious about maintainability then, to my mind, language enforced coding standards and a certain amount of "one right way to do it" has real value.
Perhaps for you.
"Maintainability" is undefined for this problem set. I can't maintain Python code because I fucking despise the language, for the same reason I don't like anal uptight bastards in three-piece suits -- it's inflexible. There's only one way of doing things, and often it is not be best way in specific situations.
For me, it always comes back to blocking. Whitespace-as-blocking is a straightjacket, chosen for aesthetics, and not for any practical reason. This design philosophy permeates Python, making it one of the ugliest languages I know.
It's like music. Any number of corporate-whore bands create smooth, aesthetic music that is bland and boring. I like my music hard, with sharp edges and dangerous points. For me, Python has always been the N*Sync of the programming world (VB is like New Kids On The Block, fwiw). Perl is more like the Pixies. LISP is like the Beatles. C is like the Stones. FORTH is like Gus' first album. Assembly is like the Black Keys. Java is like Abba.
Huh. This is kinda fun.
Now you can tell me about how programming is engineering, and not art. Go on, I know you want to.
Microsoft is to software what Budweiser is to beer.
Don't get me wrong - I'm all for having consistent and rigorous indenting once the code is finalised. I'm just irritated by the fact that the indentation has to be correct at every stage of the code development, even when I'm just experimenting with ideas. I like to be able to leave things a little messy while working on it, and then clean it up before moving to the next block of code. Using python is like having to always have a tidy desk even while you work at it.
Also I hate the stupid colons. What are they there for?
Wow...a comment on a Python story...about somebody wanting to be a lumberjack...can't....resist....
.... a Bra????
r jackSong
The Lumberjack Song from "Monty Python's Flying Circus"
Continued from Petshop, Barber, or a variety of other Python sketches....
I never wanted to do this job in the first place!
I... I wanted to be...
A LUMBERJACK!
(piano vamp)
Leaping from tree to tree! As they float down the mighty rivers of
British Columbia! With my best girl by my side!
The Larch!
The Pine!
The Giant Redwood tree!
The Sequoia!
The Little Whopping Rule Tree!
We'd sing! Sing! Sing!
Oh, I'm a lumberjack, and I'm okay,
I sleep all night and I work all day.
CHORUS: He's a lumberjack, and he's okay,
He sleeps all night and he works all day.
I cut down trees, I eat my lunch,
I go to the lava-try.
On Wednesdays I go shoppin'
And have buttered scones for tea.
Mounties: He cuts down trees, he eats his lunch,
He goes to the lava-try.
On Wednesdays 'e goes shoppin'
And has buttered scones for tea.
CHORUS
I cut down trees, I skip and jump,
I like to press wild flowers.
I put on women's clothing,
And hang around in bars.
Mounties: He cuts down trees, he skips and jumps,
He likes to press wild flowers.
He puts on women's clothing
And hangs around.... In bars???????
CHORUS
I chop down trees, I wear high heels,
Suspendies and a bra.
I wish I'd been a girlie
Just like my dear papa.
Mounties: He cuts down trees, he wears high heels
Suspendies?? and a
(spoken, raggedly) What's this? Wants to be a *girlie*? Oh, My!
And I thought you were so rugged! Poofter!
CHORUS
All: He's a lumberjack, and he's okaaaaaaayyy..... (BONG)
Stolen from here: http://bau2.uibk.ac.at/sg/python/Scripts/TheLumbe
[b.belong('us') for b in bases if b.owner() == 'you']
Or mark the first line a, the last line b and use
That was one error I consistently had, with C, C++, and Java was thinking something was conditional when it wasn't, and vice versa.
I think significant indentation is a God-send.
Now, for the colon.... I think it's just a delimiter - like "I'm done with the if condition". Like "Then" in Basic, or { in Java (with no } required).
To unindent 3 tabs, :.,.+14 3
Yes it does - I use vi - but I find that having to highlight multiple lines gets to be a real pain when the clause extends over many (e.g. > 20) lines, or involves a degree of hierarchy.
for the colon.... I think it's just a delimiter - like "I'm done with the if condition". Like "Then" in Basic, or { in Java (with no } required).
I know it looks like a delimter, but as far as I can see, unlike the {} in C it serves no syntactic purpose - the newline tells the intepreter that the body of the clause is next. All it is is an opportunity for syntax errors.
On practical grounds: ;)
white space convention in Python makes it easier to write maintainable code.
Basicaly its harder to make crappy indention. That I believe is the idea behind it. I earn my living maintaing other peoples code and believe me -- some programmers just have to do the indention their own way. Some do not use it at all. For those reasons (and some other) I prefer Python over other messy languages. Of course good coder can write beautiful code in any language. But honestly -- I have met quite few of them
... does not mean what you think it means ...
But I think you're wrong when you say the white space convention 'makes it easier to write maintainable code'. What it does is make it harder to write unmaintainable code. I happen to think it also makes it harder for me to write maintainable code, in the sense that the actual writing process is straightjacketed in a way I dislike.
I should add that I actually like almost everything in python apart from the whitespace thing - and I use it a lot!
No new line required on the IF statement in Python. So the colon is significant in that case. I'm sure there are cases where there would be syntactic confusion without it, where the IF statement is on the same line with the conditional clause.
> A lot of people have religious problems with the whitespace significance in python
I'd advise to give it a try. I understand that there are a few inconveniences. But after a few years of writing python code I find that these are very minor issues. On the plus side:
1. there is more runnable code / line of text: Just like an ACM article from many years ago suggested, I find that my comprehension of code is aided if I can see entire code blocks, functions, classes, methods, etc all at once. Python is more vertically compressed in comparison to perl, java, etc - and so easier to see more code at once.
2. no misleading indentation. The code runs the way it looks at first glance. Again, just another little feature that helps you in quickly understanding the code.
I often have to look back at code I haven't seen for 6+ months. I settled on python because it was the easiest for me to pick up again later without having to invest more time in relearning the code.
Well, you should be able to select blocks of text pretty easily. Example (in emacs ruby mode) --
1) Move cursor to start of some long if block.
2) Set the mark (C-Space)
3) C-M-f (ruby-forward-sexp) moves the cursor to the 'end'
4) Run comment-region (or uncomment-region)
The colons are there so you can do one liners like "if foo: bar()"
Boo is like Python for .NET (or MONO on Linux). Really, it is a combination of the best parts of Python, Ruby, and C#.
* It ALLOWS blocks instead of indenting in many places.
* It ALLOWS Ruby/Perl-style regular expressions natively.
* It infers types, so it can do compile-time type-checking w/o type declarations.
* It ALLOWS type declarations.
* It ALLOWS completely dynamic typing (like Python) via "duck" typing. (If it looks like a duck...)
* It is nearly as fast as C# -- that's about 15 times faster than Python or Ruby.
* It has full access to .NET/MONO.
* It facilitates .NET extensions.
* There are Boo C# converters if you want complete type-safety.
* I could go on and on. It's a very flexible language.
Is that unless you are a web application developer, Ruby's basically got nothing to offer. Not only is Rails the killer app for Ruby, it's the only app. That makes me uneasy about picking up the language.
Also, you forgot Django in your mentions of Python web frameworks.
It is really hard to convice people when recomending such a phony name language like "Python". Outside of the knowing community people were always reluctant to compliment Python.
In another words if Perl has the design of Python then i would be an giant. Python with shady syntax of Perl would be another unknown script language.
Its like the "Skoda" brand will never be a fancy sports car maker. Some people will always find it revolting to even bother.
It was designed for students.
it's a good balance between languages that are too high-level to get a good idea of what the machine is doing, and c/c++ which aren't really worth learning unless you're prepared to get into all the low-level concepts like pointers, and also learn a little bit about assembler.
two downsides are;
-it's a bit obsolete now. but fine for doing command line based stuff, even quite complex things
-a the edit-compile-run cycle of a compiled language can be quite slow if you're spending long periods of time hunting for bugs. you will be.
my password really is 'stinkypants'
I spent a while collecting python books whilst trying to get fluent in it. On the whole, they're a complete waste of time. The oreilly jython book was useful as a syntax guide (but with python having come so far since then I'd avoid it now), and the python cookbook is occasionally useful. It's one of those books you read through to learn solutions to problems you've encountered in the past, rather than in anticipation of patterns you might need.
Basically - the python online documentation is adequate. It could have a few more examples in it, it's not as practically focussed as it might be, but it's better than anything else I've seen.
Here's how I'd recommend learning python
1) discpiline yourself to sit through a slab of the
2) get really comfortable for the pattern of opening a file, reading lines from it, closing it
3) get really comfortable with the pattern for list matching, [item.getName() for item in list] - this is gold
4) try to solve a tiny problems with python a couple of times a week. It helps if it's practical. My first was a program that listed the files in a directory and wrote a html index page linking to them.
If you can get this far, you're on the right path, and you don't need any books to get there. After this point you'll find yourself dropping into the python prompt to write little scripts to solve problems, and occasionally looking for modules to do slightly interesting things and - you're not there yet - but you're going to get there from this point. As time goes on become more familiar with lambda, map and reduce - these are fantastic, powerful approaches to solving poblems. If you haven't done any functional programming it's a bit weird to start with, but stick in there, it's worth it.
Believe with me, my saplings.
Er? This sounds like it requires almost exactly the same number of keystrokes as adding/removing indentation.
I just burned through the flamewall on this issue not three days ago. I use Python instead of Perl, love Python best of all languages currently, and may even like the book reviewed. But it is superstitiously ignorant to declare any language makes it "easier" to program in. Can we just once have a discussion of the strengths and weaknesses and merits and demerits of any language at all, instead of talking about it like it was a laxative? "Makes the code soft and it flows out smoothly!" No, it doesn't: nothing does; hard programs are hard to write, easy programs are easy to write. I'll even save the time and copy my closing argument from last time:
I know a secret. It's a secret you only find out after programming for a while. It's one you obviously don't know if you ask me which programming language is the "easiest".
There is this public perception, unanimous in user-land, and even permeating to the very depths of Slashdot, which goes: "Computers are only hard because evil computer programmers deliberately set out to make them hard." And the secret is: that that's a falsehood. Computers are not made artificially difficult. It does no good to tell you this; this is a special kind of secret that you can only learn through experience.
The experience of struggling to design a usable user interface for your own system. The struggle to overcome the barriers of closed systems, lack of documentation, and misinformation everywhere you turn. The exasperation of dealing with users who come to you with the attitude that your program broke on purpose, you should fix it without knowing what the error was, and it's too hard to learn anyway because you make it difficult, because you're "evil".
Programming experience erases that mental line drawn between user and programmer. You get experience on both sides of the fence, and eventually you see that there is no such thing as artificial complication. Interfacing with a machine upon which we have taught electricity to think and where we hope to make it sing and dance for us is inherently complicated TO START WITH, and the various tools we use to perform our tasks - why, each and every one was written by average people like you and me who also sat down with a clean file and furrowed their brow and wondered "How can I do this? How can I make it so people will use it?"
No, you still have that mental mindset that there are programmers who deliberatly design things to be difficult, that it's all in spite, that they're laughing at you. Who, except as a joke, would deliberately make a programming language "hard to learn"? To fail at your task and blame your tool is simply a form of denial so that you don't have to face the fact that you have given up on trying to use something (no matter if it's COBOL or Javascript or Perl or freaking TECO, even!) that hundreds of other people have used successfully.
There is no "easy". There is no "hard". There is only "Task".
Now, you want to talk about an "easy" language? Binary, of course! Binary has just two commands (one and zero) so it's the fastest to learn, has cross-platform compatibility built-in (all computers know binary!), is easiest to test (no compiler or interpretter required, just "Rite 'n' Run"!), is readily available everwhere (ALL programs are "open source" in binary!), and needs no extension libraries (Binary can do it all!). If you thought this paragraph was stupid, this is how stupid the rest of you sound to me when you hyperfocus on "easy" and act like there's no other aspect to programming.
And learn Lisp.
Then design patterns become meaningless because there's no language limitations to try to overcome.
I mean, machines are faster everyday, and programmer time is more expensive. So it's better to use more powerful abstractions.
We are Turing O-Machines. The Oracle is out there.
I found PCL useful to get that "ohh this sh*t is powerful" feeling, but very confusing to learn lisp.
o /Commonlisp/
In contrast, this book takes your hand and teaches you in a very beginner friendly way, so you have better and long lasting foundations when you reach the end of the book:
http://www.cse.buffalo.edu/pub/WWW/faculty/shapir
We are Turing O-Machines. The Oracle is out there.
That looks really good! I think I'll start with that to get a hang of the language before moving onto PCL. Thanks a lot!
Oh come on, face it: reference were thrown into Perl as an afterthought, and they're kludgy, badly designed, overly complex, absolutely horrible and unnecessarily subtle. PHP is crippled with the exact same problem, because it's a cargo-cult programming language, which tries to ape the superficial aspects of Perl and C++, instead of having a clean well thought out design.
References in Perl and PHP disingenuously try to LOOK like C++ references by using the same punctuation character (thus misleading C++ programmers into thinking they understand what's going on), but they're each totally different ad-hoc kludges thrown in long after the base language was designed. At least C++ references are well defined in terms of pointers, so there aren't so many horrible edge cases that cause the interpreter to core dump:
Bug #30674: Unexpected results and core dump with recursive references serializing
Bug #32660 Assignment by reference causes crash when field access is overloaded (__get)
Bug #22237 PHP crashes when class references property using variable variable
Bug #34277 array_filter() crashes with references and objects
Bug #22510 Zend Engine crashes calling FREE_ZVAL from zend_assign_to_variable_reference
Bug #16387 PHP loop when using reference to an object in an object (both in session)
Bug #34137 assigning array element by reference causes binary mess
Bug #32179 xmlrpc_encode() Segmentation fault with recursive reference
Bug #31525 object reference being dropped. $this getting lost.
PHP: References Explained:
Face the reality: This is just the tip if the iceberg, a few samples of the many hard crashes caused by the half baked implementation of references in PHP, because it's such a horribly designed and deeply flawed language. Those crashes are actually caused by bugs in the programming language itself, even though the programmers were following the rules -- but there's no way of counting the zillions of actual PHP and Perl programs that crash or produce incorrect results because the people who wrote them don't understand the subtleties and limitations of PHP and Perl references.
References in Perl and PHP are unlike references in any other reasonably designed programming language: they totally suck. They're extremely hard to understand, but sometimes they still crash the interpreter, even if you do understand them perfectly and use them correctly.
-Don
Take a look and feel free: http://www.PieMenu.com
That's quite true: Haskell's notion of pattern matching is much more powerful and extensible than mere regular expressions.
Jim Clark's Haskell implementation of the derivative algorithm for validating Relax NG is a wonderful example of how powerful, elegant and concise Haskell is. Relax NG is all about tree structured regular expressions over "hedges" (mixed trees of XML elements and text). It's based on the same automata theory as regular expressions, extended to describe "hedges" (XML documents).
Another interesting Haskell library for XML is HaXml:
Here's some more stuff about Relax NG, comparing the Haskell implementation to the Java implementation (jing): Maximizing Composability and Relax NG Trivia:
Here's some interesting stuff about the design and development of Relax NG:
James Clark wrote about maximizing composability:
Clark describes the derivative algorithm's lazy approach to automaton construction:
Take a look and feel free: http://www.PieMenu.com
The language warriors miss the point: Some languages are better for some tasks than other languages.
Python is a wonderful language for part-time programmers. Why? Because Python
* is very easy to learn (no weird symbols or idioms)
* enforces indentation
* encourages legible code (few side-effects)
* encourages useful documentation (in the comments)
* encourages testing (esp. doctest)
* encourages modularity (via directory structure)
* encourages OOP (defining a class is trivial)
* can be extremely productive (with great libraries)
I work with people who need to do a lot of work in a "glue" language, but they are not professional programmers. When they use Tcl, I cannot easily re-use, maintain, or extend (via C++) their code. Perl is better, but only because the resulting code is much shorter. These people use Perl and Tcl because that's what they know. Whenever I convert someone like that to Python, they and the people who use their code become more productive.
Ruby is a wonderful language for a programmer, but is it simply not as easy to learn. The block-syntax (with ||) is awkward. Unless you know Perl, regular expressions are too terse. Modularity and OOP are simple but not trivial (which they must be or they will be ignored). Testing is easy, but documentation is as ugly as Perl's.
Also, because of its slow speed, Ruby should be considered a proto-typing language, unless the application simply does not require speed. I think Ruby is perfect for web development, because its flexibility (e.g. mixins) makes the incomprehensible almost manageable.
For proto-typing,
if the target is C++, use Ruby (or Python + Boost);
if the target is C#, use Boo;
if the target is Java, use Jython.
For embedding, I like Lua. It's small, fast, and easy to learn.
For serious, large-scale, mission-critical systems programming, there are better choices than Python and Ruby: Ocaml (or F#), Haskell, Eiffel, Scheme, Ada, etc. The experience and taste of the programmer count more here.
The competition for cheap web-hosters must be off the scale. Yet, they all compete in the same way, offering more drive space, or more download amounts. It seems like somebody would try to differentiate themselves by adding products that are free anyway.
They all seem to want to offer PHP/MySQL. Couldn't they just as easily offer Python or Perl? And maybe PostgreSQL while they're at it? Python, Perl, and PostgreSQL, are all free, so why not?
Although my experience in PHP/MySQL is limited, I consider both to be inferior technologies. PHP syntax is inconsistant, and the developers of PHP seem hell-bent on constantly breaking backward compatibily. Unlike Perl, or Python, PHP seems to be limited to web development only. I don't like MySQL's goofy subset of SQL. I also don't like MySQL strange licensing scheme. I don't like MySQL's partnership with scox either.
I offer a professional on-site Python training course (http://furius.ca/training/).
I recommend "Learning Python" (M. Lutz) to my students, over any other book. This book both offers a great introduction to the language and explains the unifying concepts much clearer than any other Python book I've seen. It also goes deep into the details if you need it. The book oozes of the many years of experience of the author in teaching the language.
(That said, I haven't read the new book being reviewed in this article.)
Thank you.
I am *so* friggin' tired of "this *N*E*W* language is *so* much better/easier to use/faster than that old language, no one should be using that anymore. Fads, that's all it is.
Then there's why should I learn this language, when I see language b, c, and d (say, Ruby and PHP) as being the New, Best-of-all?
mark
Objectionable Oriented Programming: enforcing 30 years of good programming style by compiler, for turkeys that still struggle to write spaghetti code.
.... then you need to learn a shell language and the OS utilities.
I would suggest you learn sh (Bourne Shell) first, since it is the most basic of them, is found in all UNIX or UNIX like OSes, and many modern ones are derived from it (in some systems is the shell used by default when you try to start an script).
Once you are comfortable with that try ksh or bash (but this one only if you have to). They are more versatile and adhere pretty much to sh's basic syntaxis.
IANAL but write like a drunk one.
You are an old fart. Most people here have no idea what that is :-)
IANAL but write like a drunk one.
SLOCCount statistics for Debian 3.1 (sarge): http://libresoft.dat.escet.urjc.es/debian-counting /sarge/index.php?menu=Statistics
120e6 lines of C. Perl is in 5th place with 6e6 lines, and Python is in 6th with 4e6 lines.
"written in fortran" 208,000
Didnt bother specifying Fortran4, Fortran77, Fortran90, Fortran 95
"Open the pod by doors, Hal" > "I'm afraid I can't do that, Dave" sudo "Open the pod bay doors, Hal" > alright
From bash.org http://www.bash.org/?400459:
<Sonium> someone speak python here?
<lucky> HHHHHSSSSSHSSS
<lucky> SSSSS
<Sonium> the programming language