Python is the scripting language to run home to. If you want simplicity, elegance, a good (and some may say, enough) degree of control over your system, use Python to program in. And if you think code-readability is a moot point, go use Perl and don’t read this blog anymore.
Why is Python so good? Let me take the viewpoint of a engineering teacher (a bit unconventional engineering teacher) and try to go on from there:
We all know about Algorithms, Flowcharts and the eventual program right? What I’ll propose today is a layer between the algorithm and the program. People tend to think that algorithms and programs have a one-to-one correspondence (i.e, every statement of the algorithm translates to a statement in the program.) However, any person who has written an algorithm knows that this is bull shit. Abstraction is essential if we want to present something even remotely resembling normal human-speak. The layer between the program and the algorithm, this layer that I’ll term “Monologue” for no pretty reason than that I like that name, is what makes Python so great. A real life elaboration:
c = a;
a = b;
b = c;
a, b = b, c
The first, as many might have guessed is Any Other Language. The second is Python. The advantages, the simplicity, the mode of thought change that enables every Python programmer to go a step faster than Any Other Language programmers should be evident from this very simple example.
Coming back to Vysnu, here is how you write a python function to print the first n fibonacci numbers:
def fib(n): # write Fibonacci series up to n
"""Print a Fibonacci series up to n."""
a, b = 0, 1
while b < n:
a, b = b, a+b
And so, that concludes the lesson for the day. Go shoot some balls…somewhere.
Leave a Reply