Slashdot Mirror


Text Processing in Python

Ursus Maximus writes "If you have read an introductory book or two about Python programming, but you are far from being an expert, then you will benefit a lot from reading this book. If you are a competent programmer in any other language, you will benefit from this book. If you are an expert Python programmer, you will also benefit from this book." Ursus Maximus's review continues below. Text Processing in Python author David Mertz pages 520 publisher Addison Wesley rating 10 reviewer Ursus Maximus ISBN 0321112547 summary How to use Python to process text.

As you probably know, there are many good introductory texts about Python. This is not one of them, for this is an advanced book, but not an inaccessible one. David Mertz has a unique style and focus that we have become familiar with from his series of articles on the IBM Developer Network. Dr. Mertz is more interested in facilitating our learning process than in lecturing us, and rather than fill his pages with impressive examples designed to illustrate his expertise, he gently guides us by offering subtle yet important examples of code and analysis that makes us think for ourselves.

He has a special talent for programming in the functional style, and this is a great introduction to that style of Python programming. Thus, this is also a good guide to using the newer features introduced into Python in the last few revisions, which often facilitate the functional style of programming.

The text includes, in an appendix, a 40 page tutorial covering the basic Python language. This tutorial is, like the book, unique in its approach and is worthwhile even for experienced Pythonistas, as it sheds light on some of the underlying ideas behind the syntax and semantics, and it also illustrates the functional style of programming, which is sometimes quite useful when doing text processing. And, despite its many other virtues, this is a book about text processing.

Chapter 1 covers the Python basics, but with a particular eye towards those features most critical and useful for text processing. Chapter 2 covers the basic string operations as found in the string module and the newer built-in string functions. Chapter three is about Regular Expressions, and, although I am shy about regexes because of their relative complexity, I am very glad to have read this chapter and will no longer be intimidated when regexes are the correct approach to take! Chapter 4 is on Parsers and State machines, which are important for processing nested text, as in everyday HTML, XML and the like. This chapter is not as esoteric as its title may sound to relative newbies (like myself), as it does offer useful ideas and principles for dealing with HTML. How much more useful can a topic be than that? It is true that a deep understanding of this subject may be beyond myself and other relative duffers, but this chapter has much to offer those like me and I am sure much more to offer professionals.

Chapter 5 is on Internet tools and techniques, and this a good example of how text processing touches every important area of computer programming. We manipulate text for email, newsgroups, CGI programs, HTML and many other aspects of net programming. A good summary of XML programming is included, as well as useful synopses of other Python internet modules, from a text processing point of view.

Appendix A is the aforementioned selective and short review of Python basics. Appendix B is a ten page Data Compression primer that is quite educational. Appendix C offers the same good service for Unicode, and Appendix D covers the author's own software, a state machine for adding markup to text, which is backed up by his extensive web site that has a lot of free software to support those doing extensive text processing. Lastly, Appendix E is a Glossary for technical terms from the book. This is very much an educational book, and would be suitable for classroom work at the University level, beyond the introductory programming level; in fact, as part of a curriculum to teach programming using Python at the University level, this would be an excellent text for the second course.

One of the highlights of the book is that each chapter is concluded with a problem and discussion section. These are of the highest quality I have encountered in computer texts. Rather than overwhelming the reader with a large number of problems, the author has obviously given a lifetime of thought in coming up with a few key problems that are meant to stimulate thought, creativity, and ultimately understanding and growth in the reader. I will be coming back to the problems often, as they cannot be absorbed quickly anyway; they require thought. These would be most useful in a classroom environment; but as they are accompanied by excellent discussion material, and backed up by the author's web site, the individual reader will be well served also.

The book is more than the sum of its parts. It will be a most useful reference source for when I am doing various text related tasks for some time to come, and it was also a delightful and educational quick read in the here and now. It also amply illustrates the centrality of text processing in all areas of computer science, and I am confident that the book will be useful and educational for all programmers, whatever their area of expertise.

To sum it all up, this book is educational. It is also beautifully bound and printed, and excellently written. I rate it five stars, my highest rating, and heartily recommend its purchase.

You can purchase Text Processing with Python from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

215 comments

  1. Great Intro by GoofyBoy · · Score: 3, Interesting


    Exactly who wouldn't benefit from reading this book?

    --
    The surprise isn't how often we make bad choices; the surprise is how seldom they defeat us.
    1. Re:Great Intro by damiangerous · · Score: 2, Informative

      Novice coders. You should either have some background in Python or have the fundamentals that allow you to treat languages as tools rather than being a " language X programmer."

    2. Re:Great Intro by L.+VeGas · · Score: 3, Funny

      I read that intro about five times to figure out what he was saying. Basically, if you want to learn Python, you will benefit from this book.

      or....

      This book is good. (Python is implied)

      There you go, I distilled the whole intro into four words.

      Or even better yet: Good book.

    3. Re:Great Intro by orthogonal · · Score: 0

      Ursus Maximus writes "If you have read an introductory book or two about Python programming, but you are far from being an expert, then you will benefit a lot from reading this book. If you are a competent programmer in any other language, you will benefit from this book. If you are an expert Python programmer, you will also benefit from this book."

      Why, after reading that, do I suspect Ursus Maximus will benefit if to buy this book you click a link that embeds Ursus's "associate promoter" id?

      (Note: In all fairness, I have no evidence that any such "associate id" is embedded, or that Ursus has any conflict of interest in praising this book. I'm just trying on this tin-foil hat, and pointing this out as a completely disinterested public service, that only incidently and to my complete surprise will garner me "+1 Funny" mod points. There is no man behind the curtain, Dorothy.)

    4. Re:Great Intro by odaiwai · · Score: 2, Interesting

      You know, if someone goes to the trouble of reviewing a book, what's wrong with having an affiliate link to purchase the book?

      It doesn't cost you anything extra, and it might make the reviewer a few cents. This seems a reasonable return on the work involved in writing a review.

      One of the most searched items on my site is a picture of a Rolex. I want Rolex to have an affiliate program so I can get some of that hefty green goodness.

      dave

    5. Re:Great Intro by orthogonal · · Score: 4, Insightful

      You know, if someone goes to the trouble of reviewing a book, what's wrong with having an affiliate link to purchase the book?

      In all seriousness (unlike my original post), it's a conflict of interest: the reviwer who gets compensated when readers of the review purchase the book has a great incentive not to pan the book, even if it deserves panning, because a bad review means fewer buyers means less pay-off to the "affliate" linker.

      "Affiliate" programs also drive up the cost of the books (or Rolexes), both because the affiliate must be paid off, and to cover the administrative costs of the affiliate program.

      It also means a slightly slower response time when I click the link, as the server, besides displaying the page, has to access a database to credit the affiliate -- and possibly track me all the way to purchase to see if the affiliate is to be compensated. In the case where compensation only comnes on purchase, it means another layer of tracking, and probably a web site that wants to send me cookies to identify which affiliate should get paid if I do decide to purchase. Cookies, of course, lead to individualized customer profiles and possibly higher prices when and if the tracking software decides I'll be willing to pay more than the average Joe, based on that customer profile.

      So we have conflict of interest, slightly higher costs, and customer and referer tracking. None of these things benefit me as a customer, and I prefer to avoid them.

    6. Re:Great Intro by madman101 · · Score: 1

      > Why, after reading that, do I suspect Ursus Maximus will benefit if to buy this book you click a link that embeds Ursus's "associate promoter" id I don't know why you suspect that, since it's obvious the tag on all Shashdot reviews have Slashdot's asscociate code in the links.

    7. Re:Great Intro by odaiwai · · Score: 1

      Well, in theory there could be higher prices from the factors that you mentioned, but in practice this does not seem to be the case. At least in my experience, I can buy books online cheaper than in local bookshops. If I go through someone's affilitate program, there does not appear to be a direct cost to me.

      I would guess that the money to pay for the affiliate program comes from the budget that a 'bricks and mortar' store would allocate for advertising.

      I think your point on database usage greatly exaggerates the additional time an extra SQL request takes: the website has to track your purchase through its databases anyway, adding an additional datum for affiliate_link doesn't seem like much when its already recording enough info to charge your credit card and deliver to you.

      But to the main point: "the reviewer has greater incentive to give a good review". sure, but, whith an affiliate program, we're not dealing with professional reviewers. In most cases, we're dealing with someone who's read the book, liked it and written up a review for their site.

      If someone like tomshardware.com starts getting kickbacks for good reviews, that's not good.

      If I (as an amateur) like a book, and give it a good review, and make a few cents from that, I don't see much harm. But I think the linker should explain the affiliate program and offer an optional, non-affiliate link too.

      You of course have the option of not following the affiliate link: an ideal website would have a collection of links to the subject of a review: a generic affiliate link, an affiliate link appropriate to where you are in the world (i.e. amazon.co.uk if you're in UK), a non-affiliate link, and maybe a link to a different company (e.g. CDNOW instead of Amazon.) Of course, this would require cookie tracking too, but it's an idea.

      dave

    8. Re:Great Intro by weston · · Score: 1

      "Affiliate" programs also drive up the cost of the books (or Rolexes), both because the affiliate must be paid off, and to cover the administrative costs of the affiliate program.

      Conflict of interest I'll give you, and perhaps the others as well, but not cost increase. What I think you have to look at is how affiliate payouts relate to other marketing dollars, and there's one important thing about affiliate marketing: you only pay out when you make a sale. Any other impressions or clickthroughs you get before that point is just free advertising... in many cases, per sale generated, affiliates are cheaper than other methods. And money spent on affiliate marketing is probably just a sub-portion of a total marketing budget. If they didn't spend that money on affiliate marketing, it's only marginally probable that they'd try discounts on the price of the book as another tactic. An ad campaign, product placement, review angling, other kinds of media mention... these are all just as likely.

    9. Re:Great Intro by David+Hume · · Score: 1

      Note: In all fairness, I have no evidence that any such "associate id" is embedded


      Let's see, the url of the link "Text Processing with Python from bn.com" is:

      http://service.bfast.com/bfast/click?bfmid=2181& so urceid=39391960&isbn=0321112547

      If you click through, the "sourceid=" becomes "39391960XXXXXXXXXXX," where X is an integer, and where the number "39391960XXXXXXXXXXX" becomes larger each time you click through.

      And if you click enter the url http://service.bfast.com/bfast/click?bfmid=2181&so urceid=&isbn=0321112547, thus omitting the 39391960, you still get the pertinent page.

      What do you think?

    10. Re:Great Intro by Jucius+Maximus · · Score: 1
      "Why, after reading that, do I suspect Ursus Maximus will benefit if to buy this book you click a link that embeds Ursus's "associate promoter" id?"

      I've seen similar sponsored links on slashdot before. This isn't the first time.

      But I don't know Ursus or whether or not this person is up to anything her. It's not like he's family or anything ;-)

    11. Re:Great Intro by orthogonal · · Score: 1

      But to the main point: "the reviewer has greater incentive to give a good review". sure, but, whith an affiliate program, we're not dealing with professional reviewers....

      If I (as an amateur) like a book, and give it a good review, and make a few cents from that, I don't see much harm.


      All well and good so long as there was a pretty clear distinction between "amateur" and "professional".

      A professional is someone who gets paid for his work, and an amateur is, literally, someone who does the work out of a love for it (Latin, amare, to love, being the root of "amateur"). Affiliate programs quite literally turn an amateur into a (low paid) professional; that's the point of these programs.

      But this conversion to professional status doesn't come with the traditional professional "baggage": codes of conducts, oaths, test, certifications, guild membership, peer review. A lawyer's conflict of interest is (supposedly) checked by the Bar Association and by statute law; a journalist's by his editor and his profession's code of conduct and his peers' review.

      No such check exists (or should, in any statute law sense!) for Joe Blogger or Jane Usenet Poster, or Jeff Amazon Reviewer.

      You may accuse me of exploiting the etymology of the word "amateur" to create a problem that isn't real. But the problem is even deeper than that: the distinction betweem amateur and professional has begun to disappear.

      In the "Blogosphere", it's not entirely clear who is an amateur and who's a professional. With MoveableType, anyone with the money to get a site hosted can put up a professional (that word again!) looking web site. Anyone can pontificate. And everyone has an opinion.

      How can the causual reader tell who is knowledgable and honest, and who is looking to cash in on a favorable review? During the recent war in Iraq, I got much of my news of the war from www.theagonist.org, a blog with the most current breaking news -- aand the most current breaking unsubstantiated rumors. Is Andrew Sullivan a professional pundit, a professional journalist, or an amateur blogger? Can I trust Amazon.com user reviews? Can Snopes serve as a reference in a paper on Urban Legends?

      What web site can I go to to tell me who is professional, who is amateur, who is honest, who is out to make a quick buck as an affiliate?

      And can I trust the web site that purports to make those distictions?

      So I fall back on the easy distinction: if you stand to make a buck as an affiliate, your review may be tainted -- whether you realize it or not -- by your self interest. You are perhaps no longer objective, as you're a (poorly compensated) contractor to the company you're affiliated with.

    12. Re:Great Intro by Anonymous Coward · · Score: 0

      There is absolutely nothing wrong with it, and is preferable to Bezos taking even one cent more per book sold than you can keep out of his intellectual property-profiteering pocket. I would counsel, if you must buy a book from Amazon, always buy it by following an "affiliates" link.

    13. Re:Great Intro by scrytch · · Score: 1

      > Or even better yet: Good book.

      Book is implied, it's a book review. So the review can boil down to: Good.

      --
      I've finally had it: until slashdot gets article moderation, I am not coming back.
    14. Re:Great Intro by Eythian · · Score: 1
      Of course, if it was about Perl, you could have got that down to two characters.

      Two whole words is so verbose :)

  2. The book in full by TheRoss · · Score: 5, Informative

    is here, as a series of text files. This is official.

    1. Re:The book in full by jellomizer · · Score: 5, Funny

      Why do I have a sense of fear whenever I see a link that starts with g and ends with .cx

      --
      If something is so important that you feel the need to post it on the internet... It probably isn't that important.
    2. Re:The book in full by HaloZero · · Score: 2, Funny

      It's called rectaphobia.

      --
      Informatus Technologicus
    3. Re:The book in full by Leffe · · Score: 0

      There's only one good .cx link I know of: Lowtax.

      WARNING #1: Might or might not contain an image of Mr. Lowtax.

      WARNING #2: Might or might not contain an image uploading service.

    4. Re:The book in full by Anonymous Coward · · Score: 0

      Oralse.cx isn't that bad.

    5. Re:The book in full by sutekh137 · · Score: 1

      Now, if I only I had some sort of programming language with which to process this text *throws hands in air*...

  3. Bing! by FortKnox · · Score: 1, Funny

    Ah, I see you reviewed the book that goes BING!

    --
    Good quote, too many chars. Seriously, the slashdot 120 char limit sucks!
  4. Re:But why... by isam_b · · Score: 2, Troll

    the other question is why use C# or Python for Text Processing while there is Perl !

  5. You will benefit from this book.... by revery · · Score: 5, Funny

    "If you have read an introductory book or two about Python programming, but you are far from being an expert, then you will benefit a lot from reading this book. If you are a competent programmer in any other language, you will benefit from this book. If you are an expert Python programmer, you will also benefit from this book."

    If you are a practitioner of voodoo and merely handle large pythons, you will benefit from this book.

    If you are a undersea explorer but have heard of pythons....

    --

    Was it the sheep climbing onto the altar, or the cattle lowing to be slain,
    or the Son of God hanging dead and bloodied on a cross that told me this was a world condemned, but loved and bought with blood.

    1. Re:You will benefit from this book.... by Anonymous Coward · · Score: 0

      I have a rather large python (thanks to SPAM) - will this book help me?

    2. Re:You will benefit from this book.... by Surak · · Score: 1

      If you have watched a few Monty Python skits, you will benefit from this book...

  6. Re:But why... by Slack0ff · · Score: 1, Funny

    c# what are you talking about. Im hard core Visual Basic 6 my friend. Text Process that!

    --
    Everyday You see me is the worst day of my life -Office Space
  7. Slashbot book review? by rkz · · Score: 4, Interesting

    This one is a great addition to the book shelf, I know how to do certain things in Python by using the docs, but this book clarifies nicely why you are actually doing it and provides better language specific ways of doing things that might now occur to you. Also, it introduces nice Python concepts in a clear and easy way which scripters might not have come across before.

  8. Another... by Pinguu · · Score: 4, Informative
    --
    --
    1. Re:Another... by Mister+Furious · · Score: 5, Informative

      yeah, this is a good book. also it's released under the GNU Free Documentation License and is available to download in various formats here.

    2. Re:Another... by Pinguu · · Score: 1

      Ooh I didn't relise that, thanks :)

      --
      --
    3. Re:Another... by tempest303 · · Score: 1

      YES! This is the book that got me started programming. Highly recommended for anyone who's a total newbie to programming!

  9. Re:But why... by JamesOfTheDesert · · Score: 0, Troll
    the other question is why use C# or Python for Text Processing while there is Perl

    Language war! Language war!

    I better play the trump card and end this now: Choose the *real* red pill

    --

    Java is the blue pill
    Choose the red pill
  10. Answer: by Anonymous Coward · · Score: 0

    You wouldn't. Unless you live in your parent's basement and can't afford a real development platform.

  11. I can think of one person... by Motherfucking+Shit · · Score: 3, Funny
    Exactly who wouldn't benefit from reading this book?
    Dr. David Mertz, probably... :)
    --
    "BSD: Free as in speech. Linux: Free as in beer. Windows 10: Free as in herpes." --Man On Pink Corner in #52607549.
    1. Re:I can think of one person... by Lulu+of+the+Lotus-Ea · · Score: 4, Informative

      Actually, although this remark lacks modesty, I wrote the book for myself, in a way. That is, whenever I want to remind MYSELF of a particular method in an odd little module I only use occassionally, I turn to my own explication of it. It reminds me of what I found the most important aspect when I investigated that particular feature during writing. So I benefit from having a copy too (or usually the e-copy that you can find on my website).

      Btw. I also have some author copies that I'd like to sell to US buyers who can pay by check. Basically, I get the most money if you do it that way. If that's not convenient, please buy it some other place... but if you want to drop me an email, so much the better.

      David Mertz
      http://gnosis.cx/TPiP/

    2. Re:I can think of one person... by Anonymous Coward · · Score: 0

      Oh, go back to FreeOfThoughtRepublic with your stupid, useless, illogical "rheatoric", you imbecile. It's buffoons like you who are hurting people in the world, as you bravely support the actions of civilian-killers from behind your keyboard. What a tool.

    3. Re:I can think of one person... by PizzaFace · · Score: 1
      Irregardless, I should point out -
      Sometimes it's hard to figure out whether an AC's opinions are worthwhile, and sometimes you know from the first word.
    4. Re:I can think of one person... by wigam · · Score: 1

      David this book sounds great. I learnt Python last session at uni, mainly using it to parsing HTML and XML. I'm tempted to grab your book and check it out, my methods wern't always the most eligant. But thats the way you learn a language:)

    5. Re:I can think of one person... by DoctorFrog · · Score: 1
      Irregardless, I should point out -

      Sometimes it's hard to figure out whether an AC's opinions are worthwhile, and sometimes you know from the first word.

      You mean "I"? ;)

  12. Do they ever NOT recommend the book? by SpaceRook · · Score: 3, Insightful

    Maybe it would be useful to review some BAD books. First, it would steer people away from them. Second, it would provide good examples of where a lot of tech writing goes wrong. Finally, it's just fun to read someone bash the sh!t of out something.

    1. Re:Do they ever NOT recommend the book? by donutz · · Score: 2, Insightful

      Maybe it would be useful to review some BAD books. First, it would steer people away from them. Second, it would provide good examples of where a lot of tech writing goes wrong. Finally, it's just fun to read someone bash the sh!t of out something.

      Why are you so focused on negativity? With the nightly news pushing out stories left and right about what's wrong with the world, can't we at least keep our Slashdot book reviews a good positive example of what's right with the world?

      Speaking of positive reviews, you might benefit from a book like this: The Power of Positive Thinking .

    2. Re:Do they ever NOT recommend the book? by L.+VeGas · · Score: 1, Redundant

      What's the motivation? Nobody gets affiliate fees for books that nobody buys.

    3. Re:Do they ever NOT recommend the book? by billimad · · Score: 1

      some BAD books

      SAMS - teach yourself everything yesterday

    4. Re:Do they ever NOT recommend the book? by shadow303 · · Score: 1

      They do review bad books, but they say they are good anyway. A couple years ago, I bought a book based on a good slashdot review and the book really sucked.

      --
      I've got a mind like a steel trap - it's got an animal's foot stuck in it.
    5. Re:Do they ever NOT recommend the book? by PotPieMan · · Score: 2

      Yes, in fact I didn't really recommend The Linux Problem Solver in my review from a while ago. (The formatting is not my fault.)

      Also, feel free to submit your own reviews of BAD books.

    6. Re:Do they ever NOT recommend the book? by GoofyBoy · · Score: 1

      Negativity can be fun. Its like having the same thing for dinner. Variety is good.

      --
      The surprise isn't how often we make bad choices; the surprise is how seldom they defeat us.
    7. Re:Do they ever NOT recommend the book? by MikeFM · · Score: 2, Insightful

      I recommend never buying a book that is for Idiots, Dummies, or Stupid. IMO these books suck and leave their readers little smarter for having read them.

      I have seen several series of Learn Visually books and I think they are much better in most cases. That's what I will usually give newbies to learn from.

      --
      At what price learning? At what cost wisdom? The price is a man's peace of mind, and the cost is his life.
  13. Re:But why... by tuffy · · Score: 2, Funny
    the other question is why use C# or Python for Text Processing while there is Perl !

    Why? Because then one would have to program in and maintain Perl code.

    --

    Ita erat quando hic adveni.

  14. benefits by tmark · · Score: 4, Funny

    If you have read an introductory book or two about Python programming, but you are far from being an expert, then you will benefit a lot from reading this book. If you are a competent programmer in any other language, you will benefit from this book. If you are an expert Python programmer, you will also benefit from this book

    And if you're the website posting this glowing review, and collecting affiliate fees, you will also benefit from this book.

    1. Re:benefits by Anonymous Coward · · Score: 0

      and if you are bn.com, selling books for 20-30% more than amazon.com or bookpool.com, you will benefit from the review being posted on an affiliate site.

    2. Re:benefits by Leffe · · Score: 1

      Hehe, I think they should have rephrased it a little:

      Everyone benefits from this book, including you, now, buy it!

  15. What do you use python for? by ACK!! · · Score: 3, Interesting

    I have not really used the language much but I have used a few programs like Redhat config tools that are python driven.

    What do Slashdotters use python for?

    What are its strengths and its weaknesses?

    Why is it worth learning another programming language?

    Just being curious and all that.

    --
    ACK /ak/ interj. 2. [from the comic strip "Bloom County"] An exclamation of surprised disgust, esp. i
    1. Re:What do you use python for? by Pedro_thewondermwnke · · Score: 4, Interesting

      What do Slashdotters use python for? "Fire & Forget" scripts, ie quickly fixing entries in databases as one offs. System monitors, checking the computers on our network is ok. as a calculator ;) & as a tool to unencode base64 encoded text. (I want to know that htaccess username & password ;) What are its strengths and its weaknesses? Quick to code something VERY powerfull, but slow to execute. Why is it worth learning another programming language? It's not, you already have leaned python, its just that you don't know you have! Just being curious and all that.

    2. Re:What do you use python for? by the_2nd_coming · · Score: 1

      Strengths: easy to read as white space is part of the syntax, easy to learn as the syntax is very high level, powerful becasue you can do just about any damn thing you can think of with it.

      Weaknesses: it is slower than a compiled language like C++.....ummm...I think that is all I can find

      --



      I am the Alpha and the Omega-3
    3. Re:What do you use python for? by Minam · · Score: 2, Informative

      First, a disclaimer: I haven't used Python for about a year and a half, and so may be out of touch with the most recent developments in the language. I am writing the following NOT to bash Python or to invite flames, merely to explain what I feel to be weaknesses of Python. If someone can counter them rationally, please do so.

      That said, I learned, wrote in, and loved Python for a few months. However, the whole whitespace issue eventually drove me away from Python; some people like it, I didn't.

      Second, I disliked how you had to explicitly pass "this" as a parameter to each method. It seemed very NON-object-oriented, and in a language that claimed to be OO, I found it to be a glaring discrepancy.

      Lastly, I found the regular expression handling in Python to be rather inconvenient. I much prefer the way Perl and Ruby do it (though there isn't much else I prefer about Perl).

      Other than those points, there were many things I liked about Python. Unfortunately, I can't remember enough of the language to say what they were, although it seems that operator overloading was one of them.

      ---------------

    4. Re:What do you use python for? by tuffy · · Score: 5, Informative
      What do Slashdotters use python for?

      I use it for data management, system administration chores and CGI programming.

      What are its strengths

      Python has a nice clean syntax that tends to re-use language constructs, which makes it easy to learn and read. It makes good use of objects and exceptions and it has a solid standard libarary of goodies. And, it has no shortage of additional modules to use. Plus, the whole of it is highly malleable.

      and its weaknesses?

      It's not the fastest language out there, some don't like its whitespace-based syntax and it doesn't have the breadth of pre-built modules as older languages like Perl have.

      Why is it worth learning another programming language?

      It is if you have problems to solve and don't particularly care for the tools you're using now.

      --

      Ita erat quando hic adveni.

    5. Re:What do you use python for? by Graspee_Leemoor · · Score: 1

      I use python to write 1337 5cr1p75 for Xchat.

      If you already know other languages I wouldn't say you really have to do much learning, mainly it's just the few classic moments of exclaiming:

      "What do you mean, whitespace is significant?!"

      "Where's the case statement?"

      etc.

      graspee

    6. Re:What do you use python for? by Anonymous Coward · · Score: 0

      I use it to write test harnesses. I use it as a substitute for shell scripts sometimes. It's a great language.

    7. Re:What do you use python for? by mapMonkey · · Score: 3, Informative

      However, the whole whitespace issue eventually drove me away from Python; some people like it, I didn't.

      I think you are the first person I have ever heard to hold this POV. Most people I see seem to hate the whitespace at first, and then grow to love it.

      I disliked how you had to explicitly pass "this" as a parameter to each method.

      You don't. You have have to explicitly indicate "this" (or "self" in Python) as an argument in the method definition, but you don't pass it as an argument -- Python passes it for you. That being said, Python now allows you to declare a method as a "classmethod", allowing you to call it without an instance; but you still have to have "self" in the method def, Only now, "self" is a handle on the class instead of on an instance.

      I found the regular expression handling in Python to be rather inconvenient

      The regex module has been replaced by the re module. Regular expressions have changed quite a bit in recent releases. Not sure hat your specific gripes are, but things may have changed for the better.

    8. Re:What do you use python for? by Metrol · · Score: 3, Informative

      I've recently started going through O'Reilly's "Learning Python" here myself. I'd spent a healthy bit of time trying to get C++ functionally working in my head, but I just couldn't get it. For someone who wants to code the logic and leave the nit picky stuff to someone else, Python seems to be a better approach.

      Mostly what got me going was an article in Linux Journal recently concerning wxWindows. Just the notion that I could code up a GUI application that is truly cross platform with Python and this windowing kit has got me focused on learning this language. I'm also rather interested in the fact that Python also binds in with KDE's API, as that's my preferred desktop.

      That is what all got me going. What I'm finding interesting as I learn this language is how it approaches various problems. Python is an interpereted language, but upon running a program the program is compiled into bytecode like with Java, except that the compile process is automatic. You can manually compile beforehand as well. Read a blurb in there about being able to convert a standing Python program to C, which then in turn can be compiled into a full executable. Haven't even begun to play with any of this stuff yet, but it is interesting.

      I'm personally impressed with the OOP approach that Python takes. I mostly code in PHP these days, and will most likely continue to do so for web stuff. Still, I never did much care for PHP's approach to OOP. C++'s approach just up and lost me. Python's approach seems to make a lot more sense, and even at this early stage of learning it I can see how I would utilize it in the kinds of stuff I'm looking to write.

      It has a module system similar to Perl's, and there's a LOT of them. Pretty much all the stuff I'm looking to do has some kind of module in play to help me along. I've only coded a little bit of Perl, but every time I did I really didn't care for the language. Too many esoteric symbols in place of where commands should be in play for my taste.

      I know that in every Slashdot thread concerning Python there needs to be at least one person bitching about code indenting as a part of the syntax. I personally love this. I imagine that anyone who has had to follow up behind someone who didn't indent code might just appreciate this. Python's indenting schema is pretty much exactly what I've been doing now in PHP and JavaScript for years now anyway. My eyes are still tuned in to looking for that closing brace that isn't there, but my brain is slowly starting to come around.

      At this early stage, about the only thing I'm finding a little confusing is how variables are handled. This is neither good or bad at this point, just that there's enough concepts I hadn't really dealt with before that there's a learning curve I haven't yet gotten through. From what I can tell, there's an odd mix of C++ style variables that act more like pointers than the scalars that I'm used to working with in PHP.

      This far into it, I'm still having fun going through this beginner's book. Been playing around a bit with the wxPython tutorials, and getting lost in BoaConstructor. I'm still of the opinion that my time being invested here is being well spent. Seems like a pretty cool approach to getting an application slapped together.

      --
      The line must be drawn here. This far. No further.
    9. Re:What do you use python for? by blinkylights · · Score: 1

      What are its strengths and its weaknesses?

      I would have named text-processing as one of Python's weaknesses. I wouldn't say it's bad, but it's certainly more of a PIA than in Perl or PHP. I guess I should read the book. :)

    10. Re:What do you use python for? by Anomylous+Howard · · Score: 1

      You have been away from python for a while....
      You don't pass this as an argument.
      Python now uses the same regex engine as Perl.
      As for whitespace, I use that in every laguage I program in ;)

    11. Re:What do you use python for? by mapMonkey · · Score: 1

      Oh yeah, and you can also create a "staticmethod" which does not require the first argument:

      <code>
      class MyClass:
      def noSelfMethod(numberToPrint):
      print numberToPrint
      noSelfMethod=staticmethod(noSelfMethod)

      MyClass.noSelfMethod(5)
      </code>

    12. Re:What do you use python for? by Pheersome · · Score: 3, Interesting

      I use python for everything more complex than a couple lines of shell. ~/proj/assorted_hacks/ contains stuff like a parser for libpcap dumps of AIM sessions, a script that pulls quotes out of a quotefile, a script which (using a module I wrote to parse a certain flavor of XML document) pretty-prints my bookmark URLs... I've also written a converter from the contact list format of my IM client of choice to '.blt', and at work I've written a substantial amount of CGI and some moderately tricky security-related scripts.

      Strengths: Much, much nicer to look at than perl; think "executable pseudocode" as opposed to "executable line noise". Object oriented if you want it to be. Very easy to learn, at least for someone with my background. (It took me one workday to go through the tutorial and play enough to have a decent clue what was going on; at the time I had two semesters of undergrad CS classes under my belt.) Has a good deal of the "do what I mean" quality. Development is typically very fast.

      Weaknesses: The canonical python weakness is speed, or lack thereof. I don't notice. If you're coding up something performance-intensive, don't use python. Some people don't like the indentation-as-syntax thing.

      It's worth learning another language because it'll take you just a few hours, and it's really fun.

      --
      Better to light a candle than to curse the darkness.
    13. Re:What do you use python for? by zmotula · · Score: 1

      Easy to learn and read? This is my recent new-to-Python experience:

      def bar(foo):
      for i in range(len(foo)): foo[i] = i+1

      foo = [[0] * 2] * 3
      print foo
      bar(foo[0])
      print foo

      [[0, 0], [0, 0], [0, 0]]
      [[1, 2], [1, 2], [1, 2]]

      and another one:

      Traceback (most recent call last):
      File "./imaging", line 20, in ?
      sum += image.getpixel(i, j)
      TypeError: getpixel() takes exactly 2 arguments (3 given)

      Quite lovely to read, really. Took me a hot hour to figure these out.

    14. Re:What do you use python for? by fputs(shit,+slashdot · · Score: 1

      I'm the second person who hate python white space syntax then. That was when I started using lua

      --
      I am the bastard of base minus 12! Turing was the ejaculate of my complete machine!
    15. Re:What do you use python for? by Qbertino · · Score: 5, Informative

      What do Slashdotters use python for?

      Software Agents / Content Syndication 'bots
      Web/Internet Application Server (Zope)
      3D (me: Blender, ILM for Maya and others)

      I've used Python on various things one of the more abitious being, well, actually Text Processing :-). In the wider term that is. A Software Agent for scanning and retrieving certain information from different Inet Sources - a very serial process that's hard to 'objectivise'. Python did/does a great job at keeping things overseeable.

      Zope is the other area I use Python in. Zope I consider the most sophsticated Application Server avaiable. It's GPLd of course :-) (www.zope.org)

      Just as with me Python is very popular within the 3D Field. ILM use it as their prime scripting language and I like Blenders built in Python controlled/based realtime engine.

      What are its strengths and its weaknesses?
      Shurely it's tab-based delimiting of blocks ('whitespace syntax') is a big feature. I can be shure to be able to read *any* code from anybody who did it in Python instantly. Think of how teamwork improves (especially in extreme programming) when bad indentation means your code is broken!
      Python is completely GPLd, which means a lot to me and overall futuresafety of a PL. That's why I don't feel so good about Java (allthough I like it too in a way)
      Python is very easy to learn. "Perl is executable line noise, Python is executable pseudocode" actually sums that one up.
      The only *weakness* that comes to mind is that it's a younger language. But it's catching up rapidly in terms of breadth and width of the 'lib' availability - also due to Python being completely GPLd!

      Why is it worth learning another programming language?
      It's actually one of the most modern and sophisticated. I realizes what developers theorized as ideal some 20 years ago.
      The obligatory famous quote:
      |||We will perhaps eventually be writing only small modules which are identified by name as they are used to build larger ones, so that devices like indentation, rather than delimiters, might become feasible for expressing local structure in the source language
      - Donald E. Knuth,1974|||

      Oh, and, yet again, it's GPLd all the way through. Want a better PL? Use Python.

      --
      We suffer more in our imagination than in reality. - Seneca
    16. Re:What do you use python for? by weston · · Score: 1

      I've barely begun to investigate Python, but this article is the one that convinced me it was worth a look. That, and anecdotes from half a dozen acquaintences who said essentially the same thing Eric Raymond did...

    17. Re:What do you use python for? by batlock · · Score: 1

      Zope!

      --

      Batlock...

    18. Re:What do you use python for? by axxackall · · Score: 2, Funny
      Took me a hot hour to figure these out.

      It took me 5-10 seconds to understand each example. Are you sure that software progogramming is what you should do for living?

      --

      Less is more !
    19. Re:What do you use python for? by 4of12 · · Score: 4, Informative

      it doesn't have the breadth of pre-built modules as older languages like Perl have.

      Maybe not quite as many modules as Perl, but the standard Python library provides interfaces for a lot of different tasks. It's not skimpy, in case any of you potential Python users was worried.

      There's good reason the motto is "Batteries Included".

      I've found Python useful for all kinds of tasks and love the clean, short syntax devoid of punctuation characters.

      If you need more of a recognized authority to recommend how great and wonderful is Python, then listen to Bruce Eckel or Eric Raymond.

      --
      "Provided by the management for your protection."
    20. Re:What do you use python for? by SyntheticTruth · · Score: 1

      > What do Slashdotters use python for?

      - I have used python for parsing billing dumps, comparing it to our DHCP server dumps, for audits.

      - I have written an plug-in extensible, fully functional IRC bot in python, taking advantage of it's ability to load and reload external code on the fly. All the plug-in modules from auto-op to dice randomizers are all written in python code. (And eventually, once I get it commented, it'll be released. Eventually. lol)

      - My mySQL backup/modification scripts are written in python.

      - My SSH-User's (my newbs) shells are written in python and the ncurses library. Took me a *lot* less time than trying to kludge my way through C/ncurses.

      > What are its strengths and its weaknesses?

      Strengths:
      Clean syntax. Powerful libraries. Great real-time parser. Monty Python Humor.

      Weaknesses:
      Semi-Strict syntax. It took me time, but I now enjoy the way python code writes. I do not have to worry about missing brackets, but I know some people who definately dislike python because of it. Confusing RegEx library. (At first anyways...for me.) Monty Python Humor.

      > Why is it worth learning another programming
      > language?

      For me, flexbility. And for OO-style coding, I preferred it over Perl (which I think has ugly OO.) I almost never use perl anymore, which is kind of sad, since it was my first real language after BASIC. lol

      I really disliked python at first, but over time I grew to appreciate it's strengths.

    21. Re:What do you use python for? by zmotula · · Score: 1

      Honestly: I'm not really good in progogramming.

      As for the serious part: Python is quite often described as a nice, readable language suitable for beginners. The code snippets I wrote aren't IMHO a good example of something that should be fed to beginners.

    22. Re:What do you use python for? by 73939133 · · Score: 1

      What do Slashdotters use python for?

      For the same things I would use Perl, Java, or Matlab for: CGI scripts, system administration, text processing, numerical processing, GUI application development, and many other applications.

      What are its strengths and its weaknesses?

      Strengths: easy to learn, easy to read, much better error checking than Perl, much more concise than Java, lots of libraries, lots of GUI toolkits (Gtk+, wxWindows, Qt, Tk, FLTK, others).

      Weaknesses: library modules are somewhat haphazard, no equivalent to CPAN, C implementation is rather ugly under the covers, C language interface is not very good (but still better than Perl). For short scripts, it's not as concise as Perl. While Numerical Python is "fast" in the same way Matlab is, it's still an interpreted language, and Java or C++ are a lot faster for low-level numerics and system stuff.

      Why is it worth learning another programming language?

      Python is a great language for learning how to program and for learning new concepts. It supports functional programming styles and object-oriented styles, but at the same time, it is also a very practical language.

    23. Re:What do you use python for? by psavo · · Score: 1

      So far I've used python for:
      - a X 4.3 <a href="http://iki.fi/psavo/pub/code/xcurs">curso r editor</a>
      - a thumbnailer (shortish script, ~100 LOC)
      - a file/data sorter, image classifier.

      Python was _very_ much worth learning it, best language I've used to day (unless looking at some scheme -weirdness).
      Strength is that it can implement stuff very quickly, and most thing can be runnable separately, tested.

      --
      fucktard is a tenderhearted description
    24. Re:What do you use python for? by Anonymous Coward · · Score: 0

      So you're argument is that it is possible to write non-trivial code in Python? I consider that a Good Thing (TM). May I suggest QBASIC for you?

    25. Re:What do you use python for? by jargoone · · Score: 0
      I've only coded a little bit of Perl, but every time I did I really didn't care for the language. Too many esoteric symbols in place of where commands should be in play for my taste.

      Bah. If you don't like remembering stuff, quit your crying and
      use English;
    26. Re:What do you use python for? by Jayr · · Score: 1

      On a somewhat related topic (ok, not at all), does anyone know of an XML schema validator with a PyXML interface? I've found XSV, but it doesn't follow the uniform interface of PyXML. I'm using schemas for the ability to restrict data to specific types, a feature DTDs don't provide and something I'd rather not check for in code.

    27. Re:What do you use python for? by zmotula · · Score: 1

      No, my argument is that (1) two operations that seem to be used in the same context ([0]*2 and [[0]*2]*2) probably should do the same and (2) if there's some implicit argument that gets passed to every function, it probably should not be counted when error reporting.

    28. Re:What do you use python for? by axxackall · · Score: 1
      Sorry, if I was any offensive. if you are not good at programming, but still have a motivation (you seem have as youd a patience to look at those snipplets for an hour), then you'd better go learn programming starting from high-level concepts.

      Read the book Concepts, Techniques, and Models of Computer Programming, which will teach you programming in concepts, rather than to specific language or paradigm practices. Being armored with concepts any language or paradigm will be much easier for to be understood.

      --

      Less is more !
    29. Re:What do you use python for? by Scarblac · · Score: 1

      What do Slashdotters use python for?

      All the code I wrote for my thesis (text analysis, decision trees, genetic algorithms). On the job, scripting - backup scripts, hacking up the output from a database designer program into input xml files for Torque (Java data objects library). At home, a lot of little scripts, most notably the thing that drives mpg123 for me.

      What are its strengths and its weaknesses?

      Strengths: It's fun to code. It can be extremely powerful in a few lines and still stay readable. The standard library is very powerful. Well written Python is immediately readable for someone who hasn't seen the language before. Really beautiful and flexible system of OO, object attributes, modules, functions that are first class objects, etc. Many of the constructs just make total sense when you're a computer scientist.

      Weaknesses: somewhat slow. In some situations you want to have strict compile time checks (for applications I personally use Java, not Python).

      Why is it worth learning another programming language?

      What a question! It's always worth learning another programming language, it makes you a better programmer.

      --
      I believe posters are recognized by their sig. So I made one.
    30. Re:What do you use python for? by Scarblac · · Score: 1

      The only *weakness* that comes to mind is that it's a younger language.

      This is the second time someone mentions this. Perl is from the end of 1987, Python from the end of 1989. Not enough difference to be a concern now, I'd say.

      I think Perl mostly seems older as it rode the wave of CGI scripting, and became popular as the CGI language. So a lot of people heard of it before they heard of Python, and it seems that Perl is a lot older. But really they're from the same period.

      --
      I believe posters are recognized by their sig. So I made one.
    31. Re:What do you use python for? by CableModemSniper · · Score: 1

      I would say the whole whitespace part of the syntax can be a weakness at times...but thats more of a stylistic thing then anything else.

      --
      Why not fork?
    32. Re:What do you use python for? by stm2 · · Score: 1
      I do 2 things with python:

      1) Data converting. I integrate data from diferent sources (diferents labs) using python scripts.
      2) Bioinformatics: With biopython I do very diferent tasks, like design primers in batch and data converting, but this time using the parsers included in biopython. Now I'm working on an adaptation of this program:
      SNP_Discovery I'm also making a GUI for CL program (here: GUI BLAST)

      --
      DNA in your Linux: DNALinux
    33. Re:What do you use python for? by graxrmelg · · Score: 1

      You're right about 1987 for Perl's origin, but the earliest origin for Python seems to be 1991, and it doesn't look like it actually went anywhere until 1995. In any case, age is really a proxy for the amount of development that's occurred on a language, and it still seems that Perl is way ahead on modules.

    34. Re:What do you use python for? by the_2nd_coming · · Score: 1

      but you see, that is why it is a strong point...at least from a project and cooprative programming POV.

      the fact that everyone can read and understand what you are doing becasue there is one or 2 ways to do it stylisticly is a big plus.

      --



      I am the Alpha and the Omega-3
    35. Re:What do you use python for? by Scarblac · · Score: 1

      I was going on this link, that I should have read more carefully before posting that date. Coding started late '89, it was used internally during '90, the first release was in early '91.

      But of course, there's nothing that comes close to CPAN anywhere else. It's also beautiful to see a CPAN install, automatically grabbing lots of modules and installing everything correctly :-). There are only a few Linux distributions that can do the same sort of thing, I think.

      --
      I believe posters are recognized by their sig. So I made one.
    36. Re:What do you use python for? by Anonymous Coward · · Score: 0

      What are its strengths and its weaknesses?

      If you come from C, C++, Java og Perl, Python is the most clean and elegant language you've ever known.

      If you come from Lisp or Smalltalk, you'll probably think the syntax is more "normal" or newbie-friendly, but you'll miss some features (_real_ closures, anyone? _everything_ is an object? In Smalltalk you can do "Object superclass: Object" to really screw things up. AFAIK you can't do that in Python, and that's bad.).

    37. Re:What do you use python for? by Anonymous Coward · · Score: 0

      It took me 5-10 seconds to understand each example.

      Excellent. Can you explain the first one to me? The 2nd one is no major once you're used to a couple of pythons quirks, but I can't see why passing foo[0] to the function ends up modifying foo[1] and foo[2] as well.

      Changing the function to include print lines verifies that it only changes two values, and if I manually change foo[0], foo[1] and [2] are left alone - what am I missing that's different within the function?

    38. Re:What do you use python for? by msaavedra · · Score: 3, Informative
      ...also due to Python being completely GPLd!

      While I generally agree with your post, you gave this incorrect information several times. Python is not licensed under the GPL. It uses its own unique license that is more similar to the LGPL or BSD than the GPL.

      --
      "Any fool can make a rule, and any fool will mind it."
      --Henry David Thoreau
    39. Re:What do you use python for? by Anonymous Coward · · Score: 0

      Well, I figured it out myself...

      using the [[0]*2]*3 construct creates a list of three pointers to the same sub-list... changing foo[0] changes the pointer, but changing foo[0][x] changes the contents of that list (and thus, foo[1] and [2]).

      Now why doesn't this create three separate lists?

      foo = [[0][:]*3][:]*3

      How DO you create three separate lists with this time-saving syntax? Can you?
      Seems silly to me that if I want something useless, like three copies of the same list (i.e: three copies that can't be changed without affecting the other copies) I can save time typing, but if I want three copies of the list to do something different to each one, I have to type it out long-hand to be sure I get new memory allocations.

    40. Re:What do you use python for? by Anonymous Coward · · Score: 0

      If you're coding up something performance-intensive, don't use python.
      Or better, program it in python, profile it, and actually see if it is fast enough. If not, see if you can optimize the python more. If not, you can easily write a C extension that implements the slow parts and call that from python.

      There are quite a few options that will save you time over using a lower-level language exclusively.
    41. Re:What do you use python for? by kruntiform · · Score: 1
      How DO you create three separate lists with this time-saving syntax? Can you?

      I don't think you can unless you have some sort of a loop. The most compact way I could think of was a list comprehension:
      [x[:] for x in [[0]*2]*3]
      Seems silly to me that if I want something useless, like three copies of the same list [...] I can save time typing

      It's just a bit of syntactic sugar. I can't recall ever seeing it used much. It's not really important. Besides, why do you think such a list would be useless?
    42. Re:What do you use python for? by ProfKyne · · Score: 1

      What are its strengths and its weaknesses?

      Its greatest strength is that it is incredibly quick to write, ESR wasn't exaggerating when he said that within a few hours of first learning the language he was writing fully working production-ready code. It is that easy to use. Also, Python tends to be easy to read, but really sloppy coders can still write crap Python code.

      Its greatest weakness is that it is incredibly quick to write. It is really really easy to code yourself into a hole without even realizing it. If you are writing something more than just a one-off or casual script, take a step back and give the program the same level of design consideration you would use with C or Java, otherwise you get too caught up in writing working, productive code and suddenly you realize that you're in serious need of some refactoring.

      --
      "First you gotta do the truffle shuffle."
    43. Re:What do you use python for? by Troll_Kamikaze · · Score: 2, Informative

      <<<At this early stage, about the only thing I'm finding a little confusing is how variables are handled. This is neither good or bad at this point, just that there's enough concepts I hadn't really dealt with before that there's a learning curve I haven't yet gotten through. From what I can tell, there's an odd mix of C++ style variables that act more like pointers than the scalars that I'm used to working with in PHP.>>>

      Python doesn't have variables in the traditional sense, only references to objects.
      x = 1
      causes x to refer to the immutable integer object 1, while
      x += 2
      would then create an immutable integer object with value 3 and cause x to refer the new object. This is unlike C-style languages in that in C, x would be an integer-sized slot into which we're pushing different values; in Python, x is just a name that is subsequently used as a label for various integer objects.

      However, because the objects in the example above are immutable, it's easy to mistake x for a C-style "value slot" rather than a "reference". In Python, the code
      x = 1
      y = x
      x += 2
      will not change y to 3, because y initially refers to the immutable integer object 1, as does x.

      x += 2 does not change the object that y refers to (which is 1) into 3, it just causes x to refer to a different object (the immutable integer object 3).

      Contrast the discussion of immutable objects above with the following code, which works with a mutable object:
      x = [1,2]
      y = x
      x.append(3)

      In this case, the first statement creates a list (a *mutable* sequence) containing 1 and 2, then labels the new object with the name 'x'. The second line applies another label ('y') to the same mutable sequence object.

      Since lists are *mutable*, they can be changed. The third statement changes the single mutable sequence object that both x and y refer to, so both references reflect the change. However, if the third statement had been
      x = [10,11]
      , then it would not have changed the object that y refers to; instead, it would have created a new object and applied the label 'x' to it.

      Think of it this way: If I have a domestic building that I refer to as 'my house' and you live in *the same building* with me, but you refer to it as 'mi casa', then 'my house' is affected if you burn the building that you call 'mi casa', because we're just applying different labels to the same object.

      If you build a new house for yourself and begin to refer to the new house as 'mi casa', then 'my house' (the house in which we previously lived together) would not be affected if you burned 'mi casa'.

    44. Re:What do you use python for? by Troll_Kamikaze · · Score: 1

      Also, Zope is not licensed under the GPL, but rather, a GPL-compatible license called the Zope Public License.

    45. Re:What do you use python for? by Anonymous Coward · · Score: 0

      [x[:] for x in [[0]*2]*3]

      I knew there'd be an easy way...

      Besides, why do you think such a list would be useless?

      A list of pointers all pointing to the same value? Why don't you tell me why it would be useFUL? I can't see any good reason for using three copies of the same item, when you could just use that item by itself, saving memory...

      I hereby acknowledge that me not seeing a reason for something is not the same as there being no reason ;)

    46. Re:What do you use python for? by thejackol · · Score: 1

      Slow to execute? Python? Get outta here.

      I use it on 8GB sequences (Bioinformatics) and there is quite nothing wrong with the speed. Maybe you need to improve on your algorithms?

      It's extremely quick to code something powerful and it's damn fast too. As for your last time, beautifully put! That's exactly what happened to me - I already knew it, I only had to discover it. I was going complex code way on day one!

    47. Re:What do you use python for? by jodonoghue · · Score: 2, Interesting

      What do I use Python for?
      Pretty much anything which doesn't require real-time performance (which means most things).

      To expand, I work in the Mobile Telecomms realm, so most end-user code is real-time embedded C which tends to be heavily optimised for both speed and size.

      Python is great for writing simulations, tools for processing logfiles, regression test suites (you do test, right!), and GUIs (which almost never need to have very high performance).

      Strengths:

      * I'm surprised that few people have mentioned that Python is much more expressive than C, C++ or Java - you simply get the job done in fewer lines of code, and the code is exceptionally easy to read.

      * There is a rich set of built-in data types, and good support for basic Object Orientation - it's not the most OO implementation out there, but it's more than good enough for most designs. The fact that lists and dictionaries are part of the language means you can concentrate on expressing the problem, rather than implementing yet another linked list class.

      * Very simple, regular, syntax. BTW, I'm neither especially for nor against the whitespace thing. It does mean that most Python code is stylistically similar, so it's easy to read other people's code, but it is a pain if you use different editors (or differently configured editors) to work on modules written by others: if I edit code where spaces were used for indenting and I use tabs, the code will behave unexpectedly, because Python sees a tab as equal to a single space. This can occasionally be very annoying, and difficult to track down)

      * The dynamic typing and reflection are a joy to use - simple yet powerful.

      * The ability to use a functional programming style when appropriate, without enforcing it (I personally find using FP all the time a little too rigorous - I just don't always think recursively).

      * The library covers most things - and there are excellent, really easy to use hooks to GUI libraries (I mainly use WxWindows and some Qt).

      * Easy to call C/C++ modules using SWIG - in fact it's almost trivial, so you can prototype in Python and replace the speed bottlenecks with C or C++ code to get good system performance. The profiler is quite helpful in doing this.

      * Code is usually extremely portable between Linux, other Unices and Windows.

      Weaknesses:

      * I've yet to find a really good debugger. About the best I've found is the one in Boa Constructor, but it's some way behind using, say, DDD on C++ code.

      * Performance isn't the best for serious number crunching, but it's adequate for most things.

      * It's painful to package up finished code into a 'product'. If I use Python + WxWindows + WxPython to implement a GUI for a performance analysis tool, I'll need to deliver three installers along with my code. Fortunately my end-users for this stuff are also software engineers, so they generally get the install right!

      Why learn another programming language?

      This is more a philosophical question. You can do anything in any Turing complete programming language (that'll be all of them, then), if you must.

      However, different languages tend to engender different ways of thinking about problems, so by leaning a new language, you learn new ways of thinking which can often help you in other languages you know.

      I try to learn a new language each year (so far: C, C++, Java, Shell scripting, Python, Erlang, SDL, Lisp, Perl and more assemblers than I care to remember). I've gained the most from learning C, Python and Erlang, as they each represent very different approaches to a problem.

      It's still C which earns my bread and butter - nothing else really comes close for hard real-time work - but some of the techniques I've found natural in Python have proven to translate surprisingly well into C - I'd probably not have thought of doing things that way if I didn't learn Python.

      I'd recommend any programmer who works primarily in C or C++ to learn a scripting

    48. Re:What do you use python for? by kruntiform · · Score: 1

      A list of pointers all pointing to the same value? Why don't you tell me why it would be useFUL? I can't see any good reason for using three copies of the same item, when you could just use that item by itself, saving memory...

      Here's a scenario off the top of my head: Say you initialize a list of pointers so that each one points to some "default" object. Any list item can be replaced later by a non-default object (through user action or whatever). Suppose the program wants to modify some properties of the default item at some stage. You'd only need to do that in one place if there is a single default object.

  16. So how does Python compare to perl? by Cryofan · · Score: 2, Interesting

    for text processing? Does it have the same libraries? I know it is less complicated, or that is what I hear....

    --
    eat shiat and bark at the moon
    1. Re:So how does Python compare to perl? by merlyn · · Score: 2, Insightful
      Careful. You're going to get an "emacs vs vi" debate going.

      Perl and Python have different coding philosophies. Some find Perl's flexibility better. Others find Python's rigidity better. Use what you like.

      As far as core language support and add-on modules, they both cover similar areas.

    2. Re:So how does Python compare to perl? by Anonymous Coward · · Score: 0

      Nothing to be carefull about, Randal. It is vi and perl, of course. Who needs emacs and that snaky thing?

    3. Re:So how does Python compare to perl? by Cro+Magnon · · Score: 2, Insightful

      You can go back to your Python program in 6 months and still understand it.

      --
      Slow down, cowboy! It has been 4 hours since you last posted. You must wait another few hours.
    4. Re:So how does Python compare to perl? by scrytch · · Score: 1

      "Insightful". Huh.

      I just picked up a largish complex perl program I wrote two years ago, and even though I'd written very little perl since (I wrote python and java) and it was largely uncommented, I still understood all of it just fine.

      Granted, perl gives people all kinds of ways to be "clever", so reading someone else's code can be a nightmare. Given the ease of operator overloading and creating metaclasses in python, it's quite possible to create python code that looks perfectly readable on the surface, that no one can actually really understand. Then there's Ruby, with continuations ... those let you create control structures that twist your brain in knots. Let's not even get into the evil twistedness you can perform with templates in C++, or lazy patterns in haskell.

      If you're overcome by mere syntax decoration on variables, you're far too much of a lightweight to be programming.

      --
      I've finally had it: until slashdot gets article moderation, I am not coming back.
    5. Re:So how does Python compare to perl? by screenrc · · Score: 1
      > You can go back to your Python program in 6 months and still understand it.

      That was one sentense, one sentense of mindless FUD .

      My good Sir, if you don't know enough Perl, or that matter any computer or spoken language that you will not understand six months later, I suggest that you learn the language better so you can understand later when you need it. It is very much like saying English is a horrible languge becauce I do not understand it six months later. Nonesense! The problem is in your skills, not with the language itself.

      It is much like my weak Java, I don't understand what I wrote six months ago.

  17. Python Jobs by Line_Fault · · Score: 5, Interesting

    Strangely enough, there seem to be a lot of jobs, at least where I am, where the only major language requirement is Python.
    I'm not sure if this is maintaining legacy apps, but it certainly scared me!

    1. Re:Python Jobs by semanticgap · · Score: 1

      So where are you? :-)

  18. Re:No I won't... by Anonymous Coward · · Score: 0
    If you are a competent programmer in any other language, you will benefit from this book
    I use perl...
    LOL, and perl is a language? :))
  19. Re:No I won't... by Anonymous Coward · · Score: 0

    I think you missed the word "competent." And "programmer." HTH.

  20. Why use Python? by Anonymous Coward · · Score: 0, Troll

    Isn't python 'just another language'? What 'space' does it fill, what purpose does it serve?

    For all the articles I've read about Python, it seems that it was written primarily as a replacement for Perl - i.e, more readable, usable, etc.

    But, seeing as Perl has been around for so long, has tons of support, online documentation, available code already written, why would I use Perl?

    If I'm coding a web-based application, I'll use PHP; if I'm coding Linux/Unix scripts of any degree of complexity, I'll use Perl; if I'm coding a GUI-based app, or server-side application where PHP can't do the job, I'll use Java.

    So, where the heck does Python come into play? Does the tech world really need another friggin language that emulates Perl's functionality?

    1. Re:Why use Python? by daveaitel · · Score: 4, Informative
      Well, there are 2 major drawbacks to Python:
      1. No good free runtime debugger
      2. No CPAN

      But the major benefits are that you can, with basically NO Python training, sit down at a random Python program and extend it ten times faster than an expert in C could extend THEIR OWN program.
      It's a combination of a lot of things that makes Python great to use - some of these things Perl has as well, but most of these things are very Python specific - you'll see them as you learn it.

      I recommend Wing IDE, btw, for a commercial Python editor and runtime debugger at a reasonable price.

      For what it's worth, CANVAS (http://www.immunitysec.com/CANVAS/) is written entirely in Python, so I put my money where my mouth is.

      -dave

    2. Re:Why use Python? by Anonymous Coward · · Score: 0

      Runtime debugger? What for? It is usually enough
      to have 2-4 print-statement.

      As for CPAN, there is PyPI (Python package Index).

    3. Re:Why use Python? by smallpaul · · Score: 1

      I know of at least three free debuggers. One is PDB. Another is PythonWin. And finally there is IDLE.

  21. PHP vs Python by Pedro_thewondermwnke · · Score: 1

    Does anyone know the relative speed of Python vs PHP, in a "manipulation of information in databases under high load", type situation?

    1. Re:PHP vs Python by Anonymous Coward · · Score: 1, Interesting
      in a high-load situation, the db is probably going to be the limiting factor.


      How many times have you seen slashdotted sites where the site is non-functional because of odbc or mysql errors?


      Unless you're using oracle or db2, php/python speed won't be a problem.

    2. Re:PHP vs Python by MindNet · · Score: 1

      I would also like to know, is Python faster than PHP at generic string manipulation, or sorting (of array elements) for instance?

      Right now I'm happy using PHP on the command line because I was previously comfortable using it for web sites. Is there a major reason/restriction (performance?) that I would want to learn Python, or even Perl?

      --
      "You do not associate with us because we are different. We do not associate with you because you are stupid."
  22. Boredom Processing by Slashdot by Anonymous Coward · · Score: 0

    Editors: please... if there's not much going on, please don't post not-worthy front page material to shove the decent stories down and out of sight.

    QUANTITY is not better than QUALITY.

  23. to simplify by MasTRE · · Score: 2, Funny

    "If you have read an introductory book or two about Python programming, but you are far from being an expert, then you will benefit a lot from reading this book. If you are a competent programmer in any other language, you will benefit from this book. If you are an expert Python programmer, you will also benefit from this book."
    = No matter what, you will benefit from this book.

    Do I hear a "best thing since sliced bread" coming?

    --
    Must-not-watch TV!
  24. Re:But why... by Anonymous Coward · · Score: 0

    Am i one of the only people that actually DOES use VB6 on a regular basis??! (and, although i do live with my parents and can't afford REAL development tools, i'm only 17 so i think it is reasonable!)

  25. It makes more sense to review good books. by hding · · Score: 3, Interesting

    Actually I think it's considerably less useful to review a bad book. Why? There are many, many times more books written than I will read. Therefore a bad review is most likely to warn me away from a book that I wasn't going to read anyway. And chances are (given the limited number of reviews) that no review will appear of a bad book that I planned to read.

    However, a good review may point me to a useful or interesting book that I would have otherwise overlooked.

    The obvious exception to this is when one can give a bad review to a book that is expected to have a very wide readership (and thus can warn many people away from a bad book), but how many technical books fall into this category?

  26. Text processing in Python by jdavidb · · Score: 4, Funny

    A good programmer can write Perl in any language. :)

    (Just kidding. ;) )

    1. Re:Text processing in Python by Anonymous Coward · · Score: 0

      Yes, but so can a bad one ;p

    2. Re:Text processing in Python by yanestra · · Score: 1
      A good programmer can write Perl in any language. :)

      I would rather say:

      A bad programmer writes Perl in any language.
    3. Re:Text processing in Python by JurgenThor · · Score: 1, Funny

      More so: A good one can, a bad one will

      --
      GENERAL PUBLIC SIGNATURE (GPS) Any replies (derivatives) of this post must also use the GPS
  27. Python is the Lord by ultrabot · · Score: 5, Informative

    I'm not sure if this is maintaining legacy apps, but it certainly scared me!

    Python jobs are hardly for legacy app maintenance. More like rapid development of cutting edge stuff, prototyping, exploring, enterprise application integration... and Agile development in general. I introduced Python to my previous workplace, and after the guys there learned it, they didn't switch back (even though their chief python advocate/fascist, i.e. your truly, left :-).

    Python can be used for very large problems (hundreds of modules, and much more classes), in addition to trivial scripts (0 functions). It is *fun* as hell. Python programmer is always an architect, there is very little monkey-level "grunt work", which tends to form most of your day-to-day C++/Java programming.

    You really have no clue about OOP before you have tried one of the dynamic OOP languages: Python, Smalltalk, or Ruby. Smalltalk has fallen to a legacy role these days, while Ruby is much less mature and has a smaller community than Python. Additionally, Ruby is less "tasteful", in that it borrows more heavily from perl, but that is a matter of controversy ;-).

    Additionally, Python is an embodiment of Open Source, because the code is actually readable and concise enough to lower the barrier of reading it. In fact I have taken a look at the source code of several Open Source projects that use Python "just for kicks", while I hardly bother in case of e.g. C programs. One line of Python is equivalent of 10-20 lines of C++, so you can digest more with the typical geek attention span (i.e. borderline ADD ;-).

    --
    Save your wrists today - switch to Dvorak
    1. Re:Python is the Lord by Tack · · Score: 2, Interesting
      Additionally, Python is an embodiment of Open Source, because the code is actually readable and concise enough to lower the barrier of reading it.

      At the risk of being redundant, I have to emphatically agree with this. A few years ago I started a project that required me to wrap a C library as a python module. (The project was ORBit-Python.) Having done a lot in perlXS before that, I was quite prepared to struggle with the Python/C API.

      But it wound up being truly a breath of fresh air. There are a few sticky points to get hung up on, like what functions return borrowed or new references, but the syntax is elegant and consistent, and the Python code itself is completely intuitive and a pleasure to read.

      Jason.

    2. Re:Python is the Lord by SyntheticTruth · · Score: 1

      > Additionally, Python is an embodiment of Open
      > Source, because the code is actually readable and
      > concise enough to lower the barrier of reading it.

      This is very true and important. I have written python scripts that I have had to give to non-coders to use and maintain. It's a painful, but true reality. However, python's syntax and clear code made it a lot easier to explain what the code was doing, and where to change things. For instance:

      Perl:
      if(!$AccountNumber) {
      doSomething();
      }

      Python:
      if not AccountNumber:
      doSomething()

      It's easy for us coders to easily grok $'s and @'s, etc, in perl, etc, but for teaching somebody new how to code or having to, unfortunately, but code into a non-coders hands, I vote for python hands down.

    3. Re:Python is the Lord by shawnce · · Score: 1

      You forgot Objective-C, it is a "dynamic" OOP language.

    4. Re:Python is the Lord by Anonymous Coward · · Score: 0

      Fair enough, but you clearly don't know much perl:

      $AccountNumber or doSomething();

      or, even better:

      do_something() unless $account_number;

    5. Re:Python is the Lord by King+Babar · · Score: 2, Interesting
      You really have no clue about OOP before you have tried one of the dynamic OOP languages: Python, Smalltalk, or Ruby. Smalltalk has fallen to a legacy role these days, while Ruby is much less mature and has a smaller community than Python. Additionally, Ruby is less "tasteful", in that it borrows more heavily from perl, but that is a matter of controversy ;-).

      I am not sure what you mean by Ruby being "less mature"; as a language in this niche, it appears (to me) to be among the most mature. It does have a smaller user community right now, and there are some library and documentation gaps, but nothing that could not be fixed.

      Back on the topic of text-wrangling, I should point out that Ruby is also *very* well-suited for this. So well-suited I'm not sure you'd ever want or need a big book about the subject. Do check out the Ruby Language Home Page.

      --

      Babar

    6. Re:Python is the Lord by ultrabot · · Score: 1

      I am not sure what you mean by Ruby being "less mature"

      Less modules, less community support. I also seem to remember that they only recently got kernel threads, though I might be wrong.

      --
      Save your wrists today - switch to Dvorak
  28. You sir are my hero by Anonymous Coward · · Score: 0

    You sir are my hero

    Not only have you managed to get a positive karma post down to an easy formula but you manage to harvest karma with the SAME post time and time again. I often wonder if you get modded up and I get modded down simply because people don't want to believe they have been fooled so many times. I think the realization would damage their ego.

  29. What about trusty old C? by bluethundr · · Score: 1

    I've been curious about learning Python for awhile now. But, seriously, what is the great advantage of using Python vs. C++? All I really even know about it is that it is object oriented, just like C++, but that you have to be very particular about your whitespace.

    Not sure how significant one could take this to be, but over at meetup.com, the C/C++ group looks to be a dying breed while a relative many are flocking to the Python meetings. Oh well. At least the the D&D meeting is still going strong. ;)

    --
    Quod scripsi, scripsi.
    1. Re:What about trusty old C? by k8to · · Score: 2, Informative

      The primary difference between Python and C++ is quite simple. C++ is a low-productivity language. By comparison, Python is a very high-productivity language.

      By this I mean that per line, or per time, you're getting far more done in Python. Your programs are accomplished much more quickly, and you can move on to the next job.

      Like many high-producivity languages, Python is a nicer choice than a languages like C++ except for where it's inappropriate to be used at all. Some examples include: an unusually high speed requirement, a machine-implementation oriented program, a requirement that the language meet some logistical job-world issue like available programmers or ISO spec or some such, a program that requires rigid typing in order to get close to reliability.

      The only common case there is the job-world issues.

      Note that it's quite possible to build a program in both C++ and Python using object hierarchies that span both languages.

      If nothing else, Python is excellent for prototyping C/C++ applications. Find the design errors rapidly, then implement without timewasting. I swear this is faster than writing in C/C++ the first time.

      --
      -josh
    2. Re:What about trusty old C? by 4of12 · · Score: 1

      I agree completely.

      In the end, if you find that some particular part of your Python code is limiting your performance, then code it up in C or C++ and make it available as a Python object.

      Then, you've obtained the best of both worlds: fast development and ability to quickly test, prototype in Python combined with the sheer speed of C exactly where it's needed and when (at the end, because [DEK] Premature optimization be the root of all evil.).

      --
      "Provided by the management for your protection."
    3. Re:What about trusty old C? by uradu · · Score: 1

      > If nothing else, Python is excellent for prototyping C/C++ applications.

      That's what I've been learning it for as well these last few weeks. Public methods, typeless, combined declaration/definition, all things that speed up prototyping (provided you keep in mind things that might get awkward in the final language). Another thing I've found trivial to prototype are web services; due to Python's dynamic nature, you can call remote methods as if they were real Python methods and everything gets marshalled nicely without needing fantabulous compilers. Tweaking server and client code and rerunning is almost instantaneous, much quicker than anything else I've tried so far. Heck, sometimes I even wonder why to bother implementing again in a "real" language.

    4. Re:What about trusty old C? by stm2 · · Score: 2, Insightful

      With the high speed of current computers, coding speed is more important than running/execution speed (unless you are programing a real-time data gathering device).
      Even if the program is slow, you could leave it running overnight, it cost less than average programmer hourly fee.
      5-10 years, I would have said: Learn C, but now, Python have a lot of advantages in order to be consider a "serious" languaje.
      If you are fine with C, keep with it, but I think trying python won't hurt.

      --
      DNA in your Linux: DNALinux
    5. Re:What about trusty old C? by Anonymous Coward · · Score: 0

      But, seriously, what is the great advantage of using Python vs. C++?

      Simplicity, productivity.

      C++ is a low-level language, and one of the most complex languages out there, so it's really difficult to learn and use. Which means you have to deal with very low-level stuff instead of keeping focus on problem solving.

      Python is a really hi level language. It has a simple and clear syntax, most usefuls data structures as built-ins (lists, hash etc), and built-in memory management.

      The result is that you usually need 10 to 20 time less lines of code to do the same thing in Python.

      Bugs/line percentage being somewhat stable whatever the language, this means you'll probably end up with a less buggy program.

      Another point is that Python doesnt need big compile time, so you can switch from coding to testing quite more rapidly.

      All I really even know about it is that it is object oriented, just like C++
      [disclaimer : this is only my opinion, please nobody take it for a flame war, ok?]
      C++ is somewhat static, and may not be the best exemple of an OOPL. Dynamic languages like Python, Ruby, Smalltalk, Objective C or CLOS are IMHO more naturally suited for OO. Some design patterns don't have any utility in a language like Python, due to it's dynamic nature.

      BTW, Python also allows you to write plain old procedural code, and even some bits of functional code if you like.

      Now it's as anything else : languages are tools, so let's not pretend a hammer's as screwdriver... Both are useful !-)

  30. Always with the negativity, Moriarity by burgburgburg · · Score: 1

    Always with the negativity.
    Woof, woof, woof.

  31. I am a retard - will I benefit from this book? by Anonymous Coward · · Score: 0

    It seems from this review that this book can do everything including curing the common cold. But how does the book taste? Can I eat it?

  32. What is text processing? by ENOENT · · Score: 1

    Hello? Is anybody there? Can the reviewer be bothered to say anything at all about the actual subject of the book?

    "Text processing" could mean ANYTHING AT ALL. Consider the humble Turing machine...

    --
    That's "Mr. Soulless Automaton" to you, Bub.
    1. Re:What is text processing? by Phoukka · · Score: 1

      Well, but that is pretty much the point. The book, from what I've seen from the free version on the website, is pretty general, in that it covers using Python to process text. Yes, pretty much any text. Yes, pretty much anything you want to do with text -- parse it and extract meaning, generate it, manipulate it, you-name-it. Whether it be marked-up, semantically meaningful text, or just a blob of text.

  33. Re:But why... by Anonymous Coward · · Score: 0

    Rack him, he's out.

  34. You sir are my hero by Anonymous Coward · · Score: 0

    You sir are my hero

    Not only have you managed to get a positive karma post down to an easy formula but you manage to harvest karma with the SAME post time and time again. I often wonder if you get modded up and I get modded down simply because people don?t want to believe they have been fooled so many times. I think the realization would damage their ego.

  35. Weakness/Strength: dynamic typing by DeadVulcan · · Score: 3, Interesting

    The type of object that an identifier points to cannot be declared; it's established at run-time. This is either a strength or a weakness depending on your philosophical leanings.

    It's a strength in that it makes prototyping very fast. If you want some function to operate on a class that it wasn't originally intended to operate on, then you just have to make the new class interface-compatible and jam it in there. No worrying about subclassing or prototypes or anything.

    It's a weakness for maintenance, because, when you're debugging this function, all you know is something has been passed in, and you're calling GetValue() on it. And cripes, you've got fifty six classes that have a GetValue() method! Which one is it getting? You have to run the program to find out.

    If you're doing scripting, then dynamic typing can be a godsend. If you're doing larger scale development, it can be a pain in the butt, because all of your developers need to be very disciplined.

    In general, Python is almost too powerful for its own good. If you have any undisciplined or "cowboy" programmers on your team, Python gives them enough rope to hang themselves... and everyone else... and their managers.

    But I love it. Treat it with respect, and Python will work wonders for you.

    --
    Accountability on the heads of the powerful.
    Power in the hands of the accountable.
    1. Re:Weakness/Strength: dynamic typing by Waffle+Iron · · Score: 2, Interesting

      Has anyone ever done a study to find out if the time saved by not debugging dynamic type problems is greater than the time wasted by developers worrying about compiler typing rules? In my experience, dynamic type issues are somewhat rare in a language like Python, but when programming in a language like C++ it seems that a large fraction your time can be consumed with trying to get the compiler happy with your type declarations. (Or structuring your code in an unnatural way to match someone else's type declarations. Or writing adapter layers between your type system and some library's type system.)

    2. Re:Weakness/Strength: dynamic typing by hawkestein · · Score: 1

      Studies that compare programming languages are hard to find (not to mention hard to do!). The best example I know is Lutz Prechelt, who did a comparison of C,C++,Java,Perl,Python, Rexx and TCL for one particular text-processing application. He tried to measure different things like productivity, number of bugs, memory consumption, speed, etc.

      --
      -- Will quantum computers run imaginary-time operating systems?
  36. Is Python PARTICULARLY good for text processing? by dpbsmith · · Score: 4, Interesting

    On taking a lightning-quick skimming of the text at gnosis I'm still don't quite get the point.

    SNOBOL was a mind-opener for me, because it really had a radically different approach to text processing. And it was genuinely useful. I haven't used it recently enough to know how I would feel about it today.

    Many languages now are more convenient for text processing than, say, C++ with STL or MFC. The traditional BASIC's at least recognize strings as good citizens and make it easy to do the fundamental operations. MUMPS improves on BASIC incrementally, as do PERL, Java, Javascript, etc., mostly to the degree that their standard libraries provide a useful suite of string functions. More and more languages have a Regex feature (e.g. REALBasic) and this is a really nice thing to have.

    So, I just read the review, and, as I say, took a lightning-quick browse through the online text of the book, and neither of them bothers to tell me how Python fits in.

    Both of them seem to assume from the beginning that I have already decided that Python is the language I want to use.

    Is there anything about Python that renders it especially appropriate for text processing? With regard to text processing, is it in a different category altogether from Java/Javascript/PERL/MUMPS/REALbasic?

    Or is it just a good language with string primitives and a decent string library?

  37. Perl is executable line noise, ... by Qbertino · · Score: 4, Interesting

    ...Python is executable Pseudocode.

    I have a stack of Perlbooks since something like 3 years ago and haven't gotten around to studying them thouroughly.
    Now that I've done some stuff in Python I actually think I'll never will. Everything that Perl can do Python can do better by now. Unless you're used to Unix CLI and syntax quirks Python will get you farther in a shorter period of time - and you'll be able to read your code in a year from now.
    Allthough the anual Perl obfuscation contest actually can be somewhat funny. :-)

    --
    We suffer more in our imagination than in reality. - Seneca
    1. Re:Perl is executable line noise, ... by mickwd · · Score: 2, Insightful

      Actually, your situation sounds very similar to mine. I was/am a very experienced C programmer, a pretty good shell script programmer, and with a decent knowledge of stuff like awk, sed, etc.

      Somehow I'd never got round to learning Perl, even though I thought I'd love it, as it seemed to combine the best parts of what I already knew in one single language, which many people raved about.

      Anyway, I bought a couple of the O'Reilly Perl books, and immediately started to think "Whoa, this is just too much functionality and complexity mashed together".

      Perl programmers like to say "there's more than one way to do it". Well that's OK if you're writing code - you only have to know and understand one of the many ways to implement a given task. However, if you're trying to read other peoples' code, you need to understand all of those different ways.

      I started hearing a lot about Python at about the same time I started trying to learn Perl. After finding out a little about it, I bought (another) book, and since then I've not looked back. I no longer feel the need to learn Perl any better - for me, Python is a better alternative.

    2. Re:Perl is executable line noise, ... by Junks+Jerzey · · Score: 2, Interesting

      The "executable line noise" criticism has gotten to be a standard knee-jerk reaction, and as such it has lost all meaning.

      Perl has built-in syntax for various common tasks, such as regular expression matching and common file operations (Does this file exist? What is the size of this file?). This drives the purists crazy. But if you think about it, putting the syntax directly into the language has some benefits. You can check if a file exists with a single operator. In Python, you have to remember the name of the function *and* which module it is located in, then you have to import that module. This adds up to a lot of extra mental noise.

      Or consider regular expressions. In Perl you don't have to precompile regular expressions. The compiler can see that an expression doesn't contain variables and deal with it once up front. Or if you use a variable, you can give the "o" option to an expression, indicating "compile once." In Python, you have to manually compile all expressions and reference them by id, unless you don't mind the overhead of the expression being parsed every time it is used.

      To clarify, this is not a knock on Python. Python has many of its own advantages. But simple-minded Perl bashing makes me immediately think the poster is a newbie programmer, or at least a programmer who is not well-rounded.

    3. Re:Perl is executable line noise, ... by Simon · · Score: 2, Interesting
      But if you think about it, putting the syntax directly into the language has some benefits. You can check if a file exists with a single operator. In Python, you have to remember the name of the function *and* which module it is located in, then you have to import that module. This adds up to a lot of extra mental noise.

      Which is small price to pay for readable code (and that's assuming that -f and -d, etc is easier to remember than os.path.isfile() and os.path.isdir().) I can't believe that people still think that reducing keystrokes somehow equates to improved programmer effectiveness. It's readability that counts since code is read so much more often than it is written. Hell, even a non-python programmer can read "os.path.isfile()" and guess what it does. I can't say the same about Perl's -f, -d and -e.

      --
      Simon

    4. Re:Perl is executable line noise, ... by Anonymous Coward · · Score: 0
      I must admit I'm partial to Python, too.

      However, for web site programming -- say you want to create software to maintain a blog via CGI -- then python won't get you very far. Perl is installed in virtually every web hosting service that permits CGI scripts. So, for maximum portability, you must use Perl.

      In python, you can get by with a small number of unnamed regular expressions, because the re module caches the most recently compiled regexes. However, if you use too many, then you either suffer a blow to performance, as the regexes are compiled again and again, or you compile the regexes and assign names to them. That's a lot to have to worry about, and it's a result of not having regexes built in to the language as in Perl.

      Finally, Python is much less forgiving at runtime than is Perl. For example, Perl will treat an unitialized variable as either a zero or an empty string, an the program continues to execute. In Python, if you use a variable that has never been assigned a value, it will throw an exception, which will probably cause the program to terminate. Or, Perl will happily use the string '0' as a number; Python will throw an exception. Now, I am fine with Python's pickiness when in the development or testing phase, but I much prefer Perl's laxness in deployment. The amount of damage that can be done by treating an uninitialized variable as either 0 or the empty string is rarely catastropic. But terminating a program is.

    5. Re:Perl is executable line noise, ... by Junks+Jerzey · · Score: 1

      Hell, even a non-python programmer can read "os.path.isfile()" and guess what it does. I can't say the same about Perl's -f, -d and -e.

      You're assuming too much. What does "os.path" mean? Why is "isfile" associated with this "os.path" nonsense? I know the answers, but they're not so easy to get across. Hierarchical nesting of common functions in libraries is not a good idea.

  38. GUI programming!! by Balinares · · Score: 4, Interesting

    Python and Qt are the killer combo. I once coded during a break, just for fun (and as an example for the management, alright), a complex widget that took our head VB programmer *three days*. Only the Python/Qt widget was dynamically resizable (the VB one wasn't) and could hold any subwidget (the VB one could only hold buttons).

    Now I use Python for a variety of tasks ranging from things just a little too complex to be cleanly done in Perl, to large things that usually belong in Java's sphere but are much faster coded in Python. But GUI programming is an area where it particularly shines.

    --

    -- B.
    This sig does in fact not have the property it claims not to have.
    1. Re:GUI programming!! by Anonymous Coward · · Score: 0

      Do you need both a Qt commercial license and PyQt license for commercial software?

    2. Re:GUI programming!! by Anonymous Coward · · Score: 0

      Nevermind - I just checked. You have to pay for the Qt commercial license ($1500 - $5000 depending on options) in addition to the $150 PyQt commercial license.

      Anyway, thanks for the idea of using PyQt. It looks like the best GUI binding for an interpreted language yet.

  39. You sir are my hero by Anonymous Coward · · Score: 0

    You sir are my hero

    Not only have you managed to get a positive karma post down to an easy formula but you manage to harvest karma with the SAME post time and time again. I often wonder if you get modded up and I get modded down simply because people don?t want to believe they have been fooled so many times. I think the realization would damage their ego.

  40. You sir are my hero by Anonymous Coward · · Score: 0

    You sir are my hero

    Not only have you managed to get a positive karma post down to an easy formula but you manage to harvest karma with the SAME post time and time again. I often wonder if you get modded up and I get modded down simply because people don't want to believe they have been fooled so many times. I think the realization would damage their ego.

  41. MOD PARENT WAY UP by Anonymous Coward · · Score: 0

    Great reference

    Too bad the slashbots won't get it.

  42. Re:But why... by kruntiform · · Score: 1

    Am i one of the only people that actually DOES use VB6 on a regular basis??! (and, although i do live with my parents and can't afford REAL development tools, i'm only 17 so i think it is reasonable!)

    You are in luck, my young friend. You can afford Python because it's free, and you are young enough that any brain damage caused by VB will be entirely reversible! :P

  43. You sir are my hero by Anonymous Coward · · Score: 0

    You sir are my hero

    Not only have you managed to get a positive karma post down to an easy formula but you manage to harvest karma with the SAME post time and time again. I often wonder if you get modded up and I get modded down simply because people don't want to believe they have been fooled so many times. I think the realization would damage their ego.

  44. Yeah, actually they do by Anonymous Coward · · Score: 2, Insightful

    You need to learn the Slashdot Book Rating System.

    Anything above a "9" is a good book.

    A "9" is an average book. Read it only if you are particularly interested in the subject.

    Anything below a "9" is a bad book. Avoid like the plague.

  45. PC load letter? by Smallpond · · Score: 1

    "Dr. Mertz is more interested in facilitating our learning process ..."

    What the hell does that mean?

  46. You sir are my hero by Anonymous Coward · · Score: 0

    You sir are my hero

    Not only have you managed to get a positive karma post down to an easy formula but you manage to harvest karma with the SAME post time and time again. I often wonder if you get modded up and I get modded down simply because people don't want to believe they have been fooled so many times. I think the realization would damage their ego.

  47. Here's what I like by truthsearch · · Score: 4, Interesting

    I just started learning Python a few weeks ago, with my background being C++, Java, and Visual Basic. As a side note I have to point out that Python is an absolutely fantastic option for someone wanting to switch from VB to something more modern, useful, and platform independant.

    These are the benefits of Python (mostly over C++) I personally like:
    - It's a very forgiving language; i.e. you don't need to be overly concerned about string lengths or list bounds, no pointers and simple garbage collection
    - List notations built into the syntax are extremely handy for referring to portions of the list and making changes; far less code needed for working with lists
    - The OO parts are sufficient without being complex; everything is public; multiple inheritance
    - Modules are compiled as needed and compiled version is used when available, so it's pretty quick
    - Lots of runtime information easily available

  48. Generally, you need some negative reviews... by Jerf · · Score: 4, Interesting

    Why are you so focused on negativity? With the nightly news pushing out stories left and right about what's wrong with the world, can't we at least keep our Slashdot book reviews a good positive example of what's right with the world?

    For a given reviewer, you need both positive and negative reviews so you can get a feel for what the reviewer is looking for, and how closely it matches what you are looking for. In something as subjective as books or video games, this is critical. This allows you to align your views with the reviewer.

    In this environment, where it's a different reviewer is reviewing each time, it's much less useful. Reviews are really only useful in the context of knowing something about the reviewer. (I just thought of this, and after I post this I intend to shut off reviews from my Slashdot feed, since they are uniformly useless to anybody seriously looking to use them due to this overwhelming flaw in the process.)

    In fact, the bad reviews are typically far more informative then the good ones. Most good reviews can be boiled down to "It's great!" with little loss of content, where the bad reviews have actual criticisms of the reviewed product. What you do then is read the criticisms and see if you might agree with them. If you're reading a video game review (which I use because it has great examples), and it says "Game X has far too many little numbers to keep track of for your characters", and you're old-skool and you like fiddly little numbers, then the negative review may actually boost your opinion. A lot of what appears in reviews is that sort of opinion, relatively little is concerned with universal things like "I couldn't get this game to run stably for more then 5 minutes on any of the four computers I tried it on here."

    For a book review, such negative comments really go a long ways towards clarifying what the book is. "This book didn't give any examples on how to process XML" tells you more about the book's focus then "This book is great for anyone who programs and uses text!".

    The point of "The Power of Positive Thinking", IIRC, wasn't to be unremittingly positive in every way; that's actually counterproductive and can take you out of touch with the real world. In fact, IIRC, it can best be summarized as "Don't be negative; that's bad." ;-)

  49. Python copied Perl's RE by abe+ferlman · · Score: 2, Insightful

    This happened a couple years ago. This is no longer a reason to prefer Perl.

    I haven't succumbed to Ruby for the same reason most Java-heads haven't succumbed to Python yet. I am not a Java-head because I like my programming languages free as in liberty.

    --
    microsoftword.mp3 - it doesn't care that they're not words...
  50. You sir are my hero by Anonymous Coward · · Score: 0

    You sir are my hero

    Not only have you managed to get a positive karma post down to an easy formula but you manage to harvest karma with the SAME post time and time again. I often wonder if you get modded up and I get modded down simply because people don't want to believe they have been fooled so many times. I think the realization would damage their ego.

    darn filters!

  51. Fool!! by Anonymous Coward · · Score: 1

    There is nothing Perl cannot do!! Nothing!!

    1. Re:Fool!! by Anonymous Coward · · Score: 0

      Cool, I'll write up some Perl and compile it down to assembly code for embedding in a microcontroller with barely any RAM. I'm glad to know Perl will work.

  52. Answer; Python at least by axxackall · · Score: 2, Informative
    With regard to text processing, is it in a different category altogether from Java/Javascript/PERL/MUMPS/REALbasic?

    For meaningless and arbitrary text (text without syntax/semantic or with a very primitive syntax still no semantic or when you consider text as a arbitrary set of strings despite any syntax or semantic) processing neither of imperative languages is good.

    If you want to work with text as with meaningful set of information, where both syntax and semantic should be taken to consideration and processed as well, then you need other languages. Haskell, ML, Lisp is first what comes to mind for semantic text processing. With some limits I still can include Python to the list of recommended languages for text processing as it has some elements of functional programming plus it's the most advanced scripting language among imperative ones, besides it's OOP is good enogh for the subject.

    Conclusion: if your mind is corrupted by imperative languages than choose at least Python for text processing. But if your mind is still flexible than choose Haskell or Lisp or ML.

    --

    Less is more !
  53. Really good book by Anonymous Coward · · Score: 0

    The book in question has the highly positive review
    because it is really good. I do not understand
    those talks about reviewer getting more money
    for good review: the book is excellent and
    far from average computer book in it's quality.

    Roman.

  54. Memory Corruption by Anonymous Coward · · Score: 0

    Frost Pist\n

  55. Contents of the book: by Anonymous Coward · · Score: 0, Funny

    Preface: Why Python? I have no idea.
    Introduction: After reading the Preface, you'll come to the same conclusion as I have.
    Chapter 1: use perl
    Chapter 2: use perl
    Chapter 3: use perl
    Chapter 4: use perl ...
    Conclusion: use perl, if you must use python, write your code in perl, and exec it from python.

  56. Embedding Python in HTML? by weston · · Score: 1

    Does anyone know what solutions exist for quick/diry embedding python inside HTML, ala embPerl?

    1. Re:Embedding Python in HTML? by stuntpope · · Score: 1

      Webware has as one of its components Python Server Pages.

      example:

      <% for i in range(5):
      res.write("<b>This is number" + str(i) + "</b><br>") %>

    2. Re:Embedding Python in HTML? by jrfonseca · · Score: 1

      See an article on DeveloperWorksabout that at h for doing that on the server side.

      I'm also using an home grown Python script based on that principle for my homepage. I'm actually in the process of rewriting it to use the more robust HTML and XHMTL parsing of the libxml2 python bindings, and to have even cooler stuff such as Xpath and XSLT under the control of your embedded python scripts.

      You can also do the scripting on the client side. The Win32 version ActiveState Python has support for doing that - if you're on that sort of pseudo OS... ;-)

  57. Woe to XHTML by fm6 · · Score: 2, Interesting
    The GTP site naturally links to the Open Books Project site. Here things get sort of depressing. The HTML includes a reference to the XHTML DTD at w3.org. If you try to open this page with Internet Explorer, it tries to download and parse the DTD, with unfortunate results:
    Parameter entity must be defined before it is used. Error processing resource 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'. Line 85, Position 2
    IE behaves correctly if you give it an out-of-band indication that this is HTML (such as copying the text to a file with an .html extension). Netscape seems to ignore the DTD reference, even if you feed it the code in a file with an XML extension.

    This is frustrating. I'm beginning to be a fan of XHTML and CSS. The specification are much better thought out than they use to be. There's even support for using XHTML for hard copy! But what's the point of creating content in these formats if it's inaccessible to 90% of web users?

  58. It's bad enough by Anonymous Coward · · Score: 0

    wasting so much time posting to slashdot - but worrying about your karma too much is just pathetic.

  59. As the reviewer of this book, and many on my site by Ursus+Maximus · · Score: 2, Interesting

    I'd like you to know that I am *not* an affiliate of any company's, and you can not link to Amazon or anywhere else from my site giving me a commission. I do it for love, or fun, or whatnot, but the 35 or so book reviews on my site and the rest of my site, do not earn any money anyway. www.awaretek.com/plf.html

  60. But Perl has CPAN by anonymous+cupboard · · Score: 1
    Python is probably th better language. However Perl can be written in a nice and easy to understand way. What it really has is the killer-app - well actually the library. Lots of examples of Perl code (both good and bad) and a lot of useful stuff.

    This book though is good and shows one of Pythons strengths. It is just a pity that Python didn't have such a library.

    1. Re:But Perl has CPAN by Ian+Bicking · · Score: 1

      It is being worked on -- PyPI (Python Package Index). It's quite new, so it's not as big as CPAN, and doesn't do a lot of things CPAN does (many of which I'm sure I'm unaware of) since it's just an index. But it is specifically intended to be a start on the path to CPAN. The distutils package for Python is another piece of the puzzle, to make distribution and installation easier.

    2. Re:But Perl has CPAN by murple · · Score: 1

      While something like CPAN is really missing for python, I know some perl users, who have no idea how to install something from CPAN. (I don't have either, but I don't use perl.)

      And remember: Python comes whith batteries included (ok, sattelite dish is missing)

    3. Re:But Perl has CPAN by anonymous+cupboard · · Score: 1

      CPAN modules are essentially just .tar.gz files with a Makefile.PL script to build/test/install them. It is sort of standardised and it works inside or outside the CPAN installer module. What the installer module does is act as a package manager, sorting out dependencies and updates. This is really what I'm looking for from Python.

  61. Re:Is Python PARTICULARLY good for text processing by Anonymous Coward · · Score: 0

    Gee, um, perhaps the point of the book is to show python programmers how to get the best results when processing text?

    I mean, just an idea picked up from the title of the book. I don't see why you want to read it as "Why you should use python for all your text processing".

  62. A little trivia... by yanbusa · · Score: 1

    From Python.org Python is named after the BBC show 'Monty Python's Flying Circus' and has nothing to do with nasty reptiles. Making references to Monty Python skits in documentation is not only allowed, it is encouraged! Also, many of google's engineers use Python, and I hear they are constantly looking for more people with skills in this language. From Python.org

    --
    What's in a sig?
  63. Re:As the reviewer of this book, and many on my si by scrytch · · Score: 1

    You are not an affiliate. Slashdot is. I'll give them this, slashdot wears the conflict of interest on its sleeve, as they've stated since they began doing reviews how most reviews were going to be glowing because of the affiliation.

    One might imagine that a little integrity would spur more buying of books that were well-reviewed, because the review would mean something, but apparently for now it's worth just getting mentioned on slashdot.

    Slashdot used you.

    --
    I've finally had it: until slashdot gets article moderation, I am not coming back.
  64. Python is just like Java.... by Anonymous Coward · · Score: 0

    Both are languages which NEED advocacy in order for them to be widely used.
    Languages like c, c++, and perl are widely used because they're cool, crude, and powerful, not because they have some huge advocacy group to promote them.

  65. Mime types by Anonymous Coward · · Score: 0

    This must be one of the reasons why it is bad for IE to be ignoring mime types while mime types are simultaneously the same reason why some people say they don't like non-IE browsers.

  66. Validation, not mime by fm6 · · Score: 1

    It is bad for IE to ignore mime types. But that's not the problem here. The problem seems to be that IE is trying to validate the markup against its DTD. Which would be a silly thing to do even if it didn't make the page undisplayable.

  67. Re:Is Python PARTICULARLY good for text processing by Ian+Bicking · · Score: 2, Informative
    No, Python is not particularly good for text processing. Python is very much a general-purpose language, and there's no specific task for which Python was designed.

    Text processing is, after all, only the start of things. Eating and spitting out text gets kind of boring pretty quick (see Awk or XSLT). More often you'll want to do something with that text. You'll process it then present it, email it, perform actions based on it, etc.

    That said, Python is quite good for text processing. For instance, it doesn't have a regex literal, but it does have a special string literal which doesn't parse backslashes. So regexes don't stick out quite as nicely as in Perl, but they aren't painful to write like in PHP (how many backslashes do you need in your string when looking for a backslash?). Python has a few little touches that make it work well, even if there's nothing you can point to and say "that's for text processing."

    Compared to Java, for instance, text processing in Python will be much easier and require much less code. But that holds true for any task. Compared to Perl, code written to do text processing in Python will be much more readable. Like any task. Python is just a good language.

  68. Python file processing by Ian+Bicking · · Score: 2, Interesting

    Just on the topic of file processing, the path module for Python is really cool. I'd like to see it become a part of the standard library, actually. I think it makes Python code much more on-par with Perl for that task (and I fully admit that Python's os.path functions are not very pretty).

  69. Re:What about trusty old Lisp? by Anonymous Coward · · Score: 0

    I've learned a bit about Python from some of my students who like it. Funny thing is, having worked on AI, I cannot help but feel that Python is Lisp reinvented, but *slow*. Lisp got a lot of bad fame from misinformed people who thought it was interpreted (whereas all modern Lisps have very good compilers, and compile on the fly), that predefined types were essential (as opposed to built-in polymorphism even without OO) and that garbage collection was slow. Things are achanging,
    and Python is helping that. Search for Norvig in the web, you'll find Python is about *ten* times slower than any modern Lisp, over a wide range of sophisticated AI applications.

    Nowadays I program mostly in C, because it was faster than Lisp (by a factor of about 2) and also I did need manual memory management for the high performance I need for the combinatorial (i.e. exponential complexity) problems I usually deal with. Now that I really need object orientation, I'm struggling with C++ (it really sucks for *lots* of things which are extremely simple in Lisp, e.g closures or many of the uses of the STL) and I'm reconsidering going back to Lisp, since I cannot afford the performance hit by Python.

    The great plus for Python as opposed to Lisp is, I think (as said I'm not really a python programmer) is the libraries for web programming and text processing, the easiness of programming guis (or so I'm told). Perhaps that might change for Lisp, if the various implementations would address the problem. I started using Lisp again when I found perl totally unreadable for things like hash tables of hash tables (which I needed for something as simple as parsing some experimental logs). It is amazing how a few well-defined utility functions available in the net (e.g split and the likes) can make Lisp enormously productive , and it *is* fast.

    My recommendation: do by all means learn python, it will teach new and very productive ways to program and think about problems. Then if you need performance while keeping the same style of programming, do take a serious look at Lisp.

  70. Zope by Moderation+abuser · · Score: 1

    Rocks. Muchly rocks.

    --
    Government of the people, by corporate executives, for corporate profits.