[Tutor] failing to learn python

Alan Gauld alan.gauld at freenet.co.uk
Wed Apr 12 23:15:59 CEST 2006


> can I use Python. Everyone says it is a "general programming language", 
> but what in the world is a "general programming language"?

Others have already answered this. I'll add a few other comments.
A general purpose language is one that in theory means you don't 
need any others. It can do anything. It may not do everything as 
well as special purppose tools like sed but it can do anything.

Where sys admins typically use tools like Python is in producing 
well formatted reports, particularly nowadays on web pages. 
Or maybe you have to do a lot of SQL admin on a database 
and python's database links will allow you to write a single script 
which is easier to maintain than lots of separate ones.

Where python is likely to be more useful to you is where you 
have long shell scripts rather than long awk/sed scripts. Shell 
scripts are fine as application launchers but if you need  to process 
the output of commands and have long multi way if/else chains 
the Python may offer better facilities.

But if you are working exclusively on Unix and you know the 
400+ Unix commands well you may very well have little use 
for Python. I certainly don;t use it for much sys admin stuff, 
I tend to use it to write GUI front ends for the tools, or for 
writing networking applications or testing new protocols.

One example where a tool like Python may be of use to 
you would be in building an interactive diff tool. The standard 
diff tools in Unix only allow comparison of 3 files, but if you 
have 6 or 8 versions you need to compare then using python 
you can build your own diff tool to compare 8 files if needed.
And with the low cost of disk space file management of 
concurrent versions is becoming an issue for many admins...

> The Python video said that one can take this language to good level in 1 
> afternoon, for me it has been 2 months and more. What is wrong?

Probably nothing. That claim refers to someone who is already 
fluent in another general purpose language like C or Java. Such a
programmer can indeed get to the point where they can write 
a reasonable program in Python after a few hours with the 
official tutorial. A beginner will take more like 4-6 months to 
get really comfortable. You probably fit somewhere in the middle
depending on your awk or shell skill level.

If your awk action clauses run to 10s of lines then you probably 
do know enough to learn Python quickly but if you typically only 
write 3 or 4 lines in an action clause then Python will be more 
challenging.

HTH,

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Tutor mailing list