My primary language right now is D, and I\'m in the process of learning Python because it\'s required for a course I\'m taking. While I understand why dynamic languages wou
Example in Python:
def lengths(sequence):
try:
return sum(len(item) for item in sequence)
except TypeError:
return "Wolf among the sheep!"
>>> lengths(["a", "b", "c", (1, 2, 3)])
6
>>> lengths( ("1", "2", 3) )
'Wolf among the sheep!'
How long do you think this took me to write, and how many compile-run-debug cycles?
If you think my example is trivial, I can reply by saying that dynamic languages make trivial many programming tasks.