newbie question

J

Jeremy Jones

John said:
Can python do Shell programming or system programming as perl does?
Thanks.

John
Yes. The only problem is that the perpetual migraine you have from
doing Perl and shell will quickly go away. So, if you're into pain,
stick with Perl and shell. If you want relief, come to Python.

Seriously, though, Python is an excellent language for doing sysadmin
type tasks. (I'm assuming that's kind of what you wanted?) Most
sysadmin type tasks are in modules whereas with Perl, they're cluttering
the toplevel namespace (I don't think Perl has the concept of namespace,
but you get the drift). So, not knowing what you want to do, you may
want to checkout the os module in Python (I've found os.path.* to be
specifically helpful). You may also want to checkout the shutil module.

Jeremy
 
A

Alex Martelli

Jeremy Jones said:
the toplevel namespace (I don't think Perl has the concept of namespace,

I think it does, and, like C++, it uses :: to indicate that.


Alex
 
J

James Stroud

I have done shell programming in both python and perl for some time. I love
both languages for different reasons. At the risk of sounding like language
evangelicalism, though, I will advise you to use python exclusively.
Sometimes without thinking I still reach for perl to do 'shell' scripting (by
thinking in perl and beginning with the infamous "#! /usr/bin/perl -w"). In
these cases I invariably finish and say to myself "I should have done this in
python."

Take a look at the "os" module.

James

Can python be used for shell programming?

Absolutely. Going through the python tutorial will take, say, 3 hours,
and then you should be able to decide for yourself.

As perl does?

That is a very different question I don't think I am qualified to answer.

--
James Stroud, Ph.D.
UCLA-DOE Institute for Genomics and Proteomics
611 Charles E. Young Dr. S.
MBI 205, UCLA 951570
Los Angeles CA 90095-1570
http://www.jamesstroud.com/
 
J

Jorge Godoy

James Stroud said:
I have done shell programming in both python and perl for some time. I love
both languages for different reasons. At the risk of sounding like language
evangelicalism, though, I will advise you to use python exclusively.
Sometimes without thinking I still reach for perl to do 'shell' scripting (by
thinking in perl and beginning with the infamous "#! /usr/bin/perl -w"). In
these cases I invariably finish and say to myself "I should have done this in
python."

That makes two of us. :)

But I'm going more to Python now. I used to do a lot of things faster
in Perl when I was beginning with Python, now I am a lot faster in
Python. :) The main advantage is that Python comes with batteries
included ;-)
 
C

Caleb Hattingh

Can python be used for shell programming?

Absolutely. Going through the python tutorial will take, say, 3 hours,
and then you should be able to decide for yourself.

As perl does?

That is a very different question I don't think I am qualified to answer.
 
P

Paul Watson

Jeremy Jones said:
Yes. The only problem is that the perpetual migraine you have from doing
Perl and shell will quickly go away. So, if you're into pain, stick with
Perl and shell. If you want relief, come to Python.

Seriously, though, Python is an excellent language for doing sysadmin type
tasks. (I'm assuming that's kind of what you wanted?) Most sysadmin type
tasks are in modules whereas with Perl, they're cluttering the toplevel
namespace (I don't think Perl has the concept of namespace, but you get
the drift). So, not knowing what you want to do, you may want to checkout
the os module in Python (I've found os.path.* to be specifically helpful).
You may also want to checkout the shutil module.
Jeremy

While I usually use Python, I must admit that doing:
$s = `ls -al $thefilename`
seems easier and clearer than:
import os
s = os.popen("ls -al %s" % thefilename)
 

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

Forum statistics

Threads
474,211
Messages
2,571,092
Members
47,693
Latest member
david4523

Latest Threads

Top