Perl Monk, Perl Meditation | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I suppose most Pythonistas would rather prefer making rtoa a class variable and using roman_to_dec as a method. TIMTOWTDI. ;-)Ha ha! Yes, despite the Zen of Python aiming for "There should be one -- and preferably only one—obvious way to do it" I could not help but notice when playing code golf in multiple languages that Python sometimes out-TMTOWTDI-ed them all! Also, without TMTOWTDI code golf is no fun at all and, surprisingly, code golf is way more popular in Python than Perl nowadays. The TMTOWTDI examples below were taken from:
Consider how to create a "Dear John" string in each of the four languages:
Curiously, Python is the only member of the gang of four languages to allow you to reverse the order of the two string multiply operands: That is, the string multiply operator is commutative in Python, but not in Perl or Ruby. This language idiosyncrasy makes string multiply based solutions most attractive in Python. To illustrate, note these code snippets from my string multiply based solutions to this game: This is a very rare example of Python out-golfing both Perl and Ruby. From my early 195-stroke function-based Python solution: notice the expression: Shortening the two strings above to "Take" and "Go to" for clarity, let's consider the many and varied ways of doing this in Python (TMTOWTDI): As you can see, I missed the winning Python "Slice and Dice" tactical trick in this game. In reply to Re^7: A short whishlist of Perl5 improvements leaping to Perl7 (Python TMTOWTDI)
by eyepopslikeamosquito
|
|