Is Python as capable as Perl for sysadmin work?

  • Thread starter John M. Gabriele
  • Start date
J

John M. Gabriele

I recently posted this sort of question to the c.l.p.m but
didn't get much of a response. I know a little Perl and a
little Python, but master neither at the moment.

I see that Python is a general purpose OO programming language
that finds use among some system administrators, but my guess
is that Perl is still more common in that area than Python.

For sysadmin-related tasks, is Python as useful as Perl, or
does it get clumsy when often dealing with the stuff admins
deal with on a regular basis?

At some point during some dingy job in the back boiler room
of Unix, would you find yourself saying, "geez, I'd wish I
started this with Perl -- Python just isn't cutting it." ?

Thanks,
---J
 
B

beliavsky

John said:
I recently posted this sort of question to the c.l.p.m but
didn't get much of a response. I know a little Perl and a
little Python, but master neither at the moment.

I see that Python is a general purpose OO programming language
that finds use among some system administrators, but my guess
is that Perl is still more common in that area than Python.

For sysadmin-related tasks, is Python as useful as Perl, or
does it get clumsy when often dealing with the stuff admins
deal with on a regular basis?

I'm a Windows user, not a Unix sysadmin, but I've noticed that
Cameron Laird has written several articles on Python for system
administration in Unix Review and Sys Admin magazine, for example
http://www.unixreview.com/documents/s=9083/sam0401d/ . Reading his
articles may help you decide if Python is a good fit for your work.
 
A

Aahz

For sysadmin-related tasks, is Python as useful as Perl, or does it get
clumsy when often dealing with the stuff admins deal with on a regular
basis?

At some point during some dingy job in the back boiler room of Unix,
would you find yourself saying, "geez, I'd wish I started this with
Perl -- Python just isn't cutting it." ?

Not likely. I'm a programmer, not a sysadmin, but my company's too
small for a sysadmin, so I and the other two programmers get elected.
(For example, today most of my time was spent hunting down kernel
patches for Red Hat 7.3 -- long story.)

Anyway. Have you ever noticed how shell scripts keep getting longer?
Ever notice how it gets harder to figure out what the heck any given
script's doing? Well, that's where Python helps you out compared to
Perl. Python can be a bit clumsier than Perl for dirt-simple tasks, but
you'll find that Python scales much better than Perl.
--
Aahz ([email protected]) <*> http://www.pythoncraft.com/

"The joy of coding Python should be in seeing short, concise, readable
classes that express a lot of action in a small amount of clear code --
not in reams of trivial code that bores the reader to death." --GvR
 
R

Roy Smith

"John M. Gabriele said:
I recently posted this sort of question to the c.l.p.m but
didn't get much of a response. I know a little Perl and a
little Python, but master neither at the moment.

I see that Python is a general purpose OO programming language
that finds use among some system administrators, but my guess
is that Perl is still more common in that area than Python.

For sysadmin-related tasks, is Python as useful as Perl, or
does it get clumsy when often dealing with the stuff admins
deal with on a regular basis?

At some point during some dingy job in the back boiler room
of Unix, would you find yourself saying, "geez, I'd wish I
started this with Perl -- Python just isn't cutting it." ?

Thanks,
---J

Given that Perl was *designed* for sysadmin work, it's not surprising that
there are some features of it which make it very convenient to use in that
arena. For executing external commands, nothing really comes close to
Perl's back-tick syntax. For doing things like reading a sequence a files
and filtering the combined contents with regular expressions, Perl is
probably the tool that lets you do that in the most compact way.

As a general-purpose programming language, it sucks. My personal opinion
is that the general-purpose suckitude outweighs the domain-specific
sysadmin convenience.
 
N

Nick Vargish

John M. Gabriele said:
At some point during some dingy job in the back boiler room
of Unix, would you find yourself saying, "geez, I'd wish I
started this with Perl -- Python just isn't cutting it." ?

Sometimes I have to write a quick script in Perl because Python isn't
ubiquitous enough around here, and I often find myself thinking I
the opposite... "Perl just isn't cutting it."

And I spent several years putting food on the table with Perl, so it's
not like I'm a noob with Perl.

Nick
 
J

John M. Gabriele

Aahz said:
[snip]

Anyway. Have you ever noticed how shell scripts keep getting longer?
Yup.

Ever notice how it gets harder to figure out what the heck any given
script's doing?
Yup.

Well, that's where Python helps you out compared to
Perl. Python can be a bit clumsier than Perl for dirt-simple tasks, but
you'll find that Python scales much better than Perl.

Check. Thanks Aahz. :)
 
J

John M. Gabriele

Nick said:
Sometimes I have to write a quick script in Perl because Python isn't
ubiquitous enough around here, and I often find myself thinking I
the opposite... "Perl just isn't cutting it."

And I spent several years putting food on the table with Perl, so it's
not like I'm a noob with Perl.

Nick

Thanks Nick (and everyone else) for the replies. Much appreciated.
 
J

Jeff Epler

No.

Unlike Perl, Python implements only a *finite turning machine* model of
computation. An easy way to see this limitation is in the following
code: 0.10000000000000001
In an infinite Turning machine, there would be an unbounded number of
zeros before the second 1, giving the exact result, not a numeric
approximation.

There's another little-known fact about Python: No string is permitted
to end with a backslash! You might think that variations like
r'\'
or
""""""\\\\\""""""
would allow you to create this elusive value, but you'd mistaken!
Now, this may not bother Unix sysadmins, but the honest truth is that
you'll be administrating Windows systems, too, anywhere you work!

Finally, Python just doesn't respond to threats as well as Perl does.
I have run into many Perl programs that just didn't quite work right
until I wrote '... or die "$!"' in the right places. Well, if you ever
have to threaten Python, just keep in mind that '... or die' just plain
won't work. You have to suggest that it 'try ... except', which is
really offensive. If I want to beg my computer to run programs, I know
where to find Intercal with its "PLEASE" and "DO PLEASE" constructions.

Jeff

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFCCP7WJd01MZaTXX0RAmCAAKCeRhKyxIfY0CE7IXce+v9z5z3wTQCghTqH
VKdS8hwqlr7zWdm8piCRdbY=
=bbHJ
-----END PGP SIGNATURE-----
 
M

Marc Huffnagle

Jeff said:
There's another little-known fact about Python: No string is permitted
to end with a backslash! You might think that variations like
r'\'
or
""""""\\\\\""""""
would allow you to create this elusive value, but you'd mistaken!
Now, this may not bother Unix sysadmins, but the honest truth is that
you'll be administrating Windows systems, too, anywhere you work!
\

Marc
 
P

Peter Maas

Jeff said:
There's another little-known fact about Python: No string is permitted
to end with a backslash!

Sure you meant string literals. But that is wrong, too:
\

A Python string mustn't end with an *odd* number of backslashes. Other-
wise a literal using backslash escapes like 'don\'t do that' couldn't
be parsed.
Now, this may not bother Unix sysadmins, but the honest truth is that
you'll be administrating Windows systems, too, anywhere you work!

This is no problem, thanks to os.path.join() ;)
Well, if you ever
have to threaten Python, just keep in mind that '... or die' just plain
won't work. You have to suggest that it 'try ... except', which is
really offensive. If I want to beg my computer to run programs, I know
where to find Intercal with its "PLEASE" and "DO PLEASE" constructions.

Sysadmin work with Intercal? Go ahead! ;) But what's wrong with a
protecting try .. except block vs. "... or die" for every command
to be protected?
 
P

Peter Maas

Jeff said:
Unlike Perl, Python implements only a *finite turning machine* model of
computation. An easy way to see this limitation is in the following
code:
0.10000000000000001
In an infinite Turning machine, there would be an unbounded number of
zeros before the second 1, giving the exact result, not a numeric
approximation.

Boy, you are cheating us!!!! Wake up, this isn't April 1st! :)))
 
M

Max M

Jeff said:
No.

Unlike Perl, Python implements only a *finite turning machine* model of
computation. An easy way to see this limitation is in the following
code:
0.10000000000000001
In an infinite Turning machine, there would be an unbounded number of
zeros before the second 1, giving the exact result, not a numeric
approximation.

Another thing is that in Perl it turns left, while in Python it turns
right. hence the .rfind() string method.

Well, if you ever
have to threaten Python, just keep in mind that '... or die' just plain
won't work. You have to suggest that it 'try ... except', which is
really offensive. If I want to beg my computer to run programs, I know
where to find Intercal with its "PLEASE" and "DO PLEASE" constructions.

Wasn't there talk about a "try harder" recently?

try:
statement
tryharder:
statement


--

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
 
N

Nick Craig-Wood

Jeff Epler said:
Finally, Python just doesn't respond to threats as well as Perl does.
I have run into many Perl programs that just didn't quite work right
until I wrote '... or die "$!"' in the right places.

I find

'... or die "You $@$!"'

works even better ;-)

Thanks for a very amusing post!
 
R

Roy Smith

Max M said:
Another thing is that in Perl it turns left, while in Python it turns
right. hence the .rfind() string method.



Wasn't there talk about a "try harder" recently?

try:
statement
tryharder:
statement

How about the Yoda version:

do:
statement
do not do:
statement
 
S

Steve Horsley

Jeff said:
If I want to beg my computer to run programs, I know
where to find Intercal with its "PLEASE" and "DO PLEASE" constructions.
Was it INTERCAL that had the COMEFROM <Line number> statement instead of
GOTO? I REALLY like the idea of a COMEFROM statement. I think python should
have a COMEFROM statement, but since perl revels in being impenetrable, I
suppose perl is likely to get it first. Shame.

Steve
 
G

Greg Ewing

Jeff said:
Unlike Perl, Python implements only a *finite turning machine*

That's interesting -- I didn't know Python could be
used as a lathe. You learn something new every day!

I suppose an "infinite turning machine" would
be a really *big* lathe...
 
C

Courageous

My opinion:

If "scales" refers to the /manageability/ of the code produced,
I'd say that Python scales better than C++. I would /much/ rather
manage a million lines of Python than a million lines of C++.

*checks self to see if self is wearing rose colored glasses*

*doesn't think so*

C//
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top