[Tutor] failing to learn python

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Wed Apr 12 21:23:01 CEST 2006



On Wed, 12 Apr 2006, Payal Rathod wrote:

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

One idea behind a "general purpose programming language" is that it's not 
specialized toward anything in particular.  It's meant to be malliable and 
a bit formless.  A programmer makes what one can with it.


> e.g. for parsing log files with regex I rather use egrep than Python. 
> For counting the number of mails received for a user I use awk

And for text parsing and processing, I think that's perfectly right, and 
you're using the best tools for that application.  (Actually, you might 
want to look into Perl, which integrates regexes very deeply into its 
language.)  You're more effective with those tools because awk and sed are 
domain-specific: they are specifically designed to do text processing very 
well.


You can think of Python as a tool-maker.  If you already are working in 
solely in one domain, where there are already plenty of tools already 
written for you, then you may not get so much out of a general-purpose 
language.  This point is made in an amusing way in Literate Programming:

     http://www-cs-faculty.stanford.edu/~uno/lp.html

The story goes that Knuth, when given the common-words problem, wrote up 
beautiful algorithm, designed a cool data structure to support it, and 
wrote it all in literate programming style.

Bentley, on the other hand, used awk and other shell utilities, and in a 
few minutes, got a more correct solution.  *grin*



> But what does Python excel at. That si my main question. Whatevfer I 
> think of I can already do or know a way to do in shell. I am not getting 
> where would I need Python.

But _someone_ had to write awk and sed: they didn't come fully-formed from 
the head of Zeus.

That's what a general-purpose language like Python is for.  You wouldn't 
write a web application in sed or awk because those two languages have 
limitations on what they're allowed to touch.


> 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?

No, you're not wrong.  Anyone who says that programming can be learned in 
an afternoon is selling something.  *grin*


More information about the Tutor mailing list