(follows from ‘Refactoring, the triangle project overview)
Through this series of blogs, I want to record my pythonic adventures and refactor my existing code to reflect my new skills. In the Triangle Project, I must develop some code to print the outline of a triangle. The triangle must be able to be printed either upright, or upside down.
Hacking it up: above is my first attempt to hack this up. It is quick and dirty, but does the job. Below, you will see my first attempt to refactor it using recursion.
Improvement from the initial hack (v1.0) to the recursive solution (v2.0):
To be honest, using a recursive function does not actually make any difference to this program. It is not any more elegant or abstracted than a simple for loop could achieve. However, the script is about 20% shorter.
The real improvements in v2.0 include: