That's really high-level: bits of beautiful python

Max rabkin at mweb[DOT]co[DOT]za
Tue Feb 21 14:05:53 EST 2006


I have a friend who has been programming in C for many years, and he is 
a great fan of the language. However, he (and I) are about to start a 
python course, and he has been asking me a lot of questions. He often 
responds to my answers with "Urgh! Object-orientation!" and suchlike.

But today we were discussing the problem of running externally-provided 
code (e.g. add-on modules). Neither of us knew how to do it in C, though 
I suggested using DLLs. However, I quickly installed python on his 
laptop and coded this:

exec "import %s as ext_mod" % raw_input("Module: ")
ext_mod.do()

And created to sample modules with do() functions to demonstrate. He was 
impressed ("That's really high-level" were his words).

I was just thinking perhaps we should create some kind of collection of 
bits of "impressive" code like this.

He also liked 99 Bottles in one line:

print '\n'.join(["%d bottles of beer on the wall." % i for i in 
range(100,0,-1)])

--Max



More information about the Python-list mailing list