Python for system administrators (developerWorks)
Python for system administrators (developerWorks)
Posted Sep 7, 2007 7:51 UTC (Fri) by oak (guest, #2786)In reply to: Python for system administrators (developerWorks) by madscientist
Parent article: Python for system administrators (developerWorks)
I don't understand what's the problem in using regrexps in Python.
Yes, they need a bit more code around them than in Perl (in Python you
explicitly compile your regexps for better performance and you get "match"
objects from the regexp matches), but at least they don't create
side-effects behind your back.
I would choose on any day a language which requires writing a bit more,
but when there's a problem, it's obvious why it happens (Perl: write 10
minutes, debug 1 hour; Python: write 15 minutes, debug 5 minutes).
As to which one is a system administrators' language, for example many
RedHat and Ubuntu system administrator tools are written in Python. I
guess if you would count the lines of code in the normal desktop install,
there could be more Python than Perl (or Php :)).
Posted Sep 7, 2007 15:37 UTC (Fri)
by madscientist (subscriber, #16861)
[Link]
I didn't say there was one: this threadlet is discussing whether REs in general constitute unclear coding constructs and should be avoided. I personally believe that REs are almost always the best way to manage string manipulation: they are succinct but straightforwardly understandable, and I was saying that I even use them in non-scripting languages such as C or C++ when I need to parse strings. The question asked was if there really were two classes of people: those who grok REs and those who don't. I don't know but it's an interesting question.
> I would choose on any day a language which requires writing a bit more,
Needless to say I disagree with your assertion. Using -w and "use strict;" mode in Perl, along with a bit of discipline to avoid egregiously bizarre constructs at the expense of a bit of typing (which is not at all difficult, really--and needed in virtually any language, as the article being referenced here obviously shows!!), and Perl is just as straightforward to read and write as any other language. I've written HUGE packages in Perl, using lots of Perl OO, complex data structures, etc. and they were no more complex to read, and took no longer to create, than code of the same complexity in any other language (and less than many).
I like Perl because I like Lisp, or at least Lisp-like thinking, and I can write Perl in that mode and it's still easily understandable to people who don't have a Lisp background. I can't remember the last time I wrote a loop in Perl that used an iterator variable, for example. I find map{} to be a perfect operator: it's immensely powerful while at the same time getting out of your way syntactically and letting you understand what the code is doing, instead of the details of how it's done. I guess my brain is wired more closely to Larry Wall's than to Guido van Rossum's :)
Anyway, this is not the place for a language war, as others have said. I think Python is great and I think you can be extremely productive in it. I use Python all the time and I've written my fair share of Python scripts. I just don't think Perl is as horrible as many Python programmers seem to think that it is, and I have no problem at all creating maintainable, readable Perl even for large, complex systems.
> I don't understand what's the problem in using regrexps in Python.Python for system administrators (developerWorks)
> but when there's a problem, it's obvious why it happens (Perl: write 10
> minutes, debug 1 hour; Python: write 15 minutes, debug 5 minutes).