Main Content

The elegance of Python

Archive - Originally posted on "The Horse's Mouth" - 2005-01-19 06:35:27 - Graham Ellis

If I need a little utility and I'm running a Perl course, then I'll write it in Perl. Training in Tcl ... then that's the scripting language to use for other requirements that day (two languages in a day is too much). And of course if I'm running Python Programming it has to be .....

MY GOODNESS - what an elegant language Python is!


import os
have = os.listdir(".")
for fname in have:
print "-" * 30,fname
fh = open(fname,"r")
for cline in fh.xreadlines():
print cline,


That little script took all the examples I'd written into a directory and packaged them into a single file - bit of redirection and emailing, and all the trainees had a copy.