Beautiful, Beautiful Python
Today I was working on a USA ePay payment module for Satchmo. I had access to some work done by another chap, but I wanted to get a better feel for what needed to be happening in the payment module, so I examined some of the stuff that other people had done as well. I studied the "official" PHP version of the payment module for a little while. Things seemed pretty self-explanatory, so I decided I might as well translate the PHP library into Python.
Most of the translation process was quite mundane... removing dollar signs here and there, getting rid of the dirty -> junk, etc. However, toward the end of the translation process, I started to actually enjoy myself. That's because I wasn't just defining variables left and right--I actually started doing some stuff for processing. Here's some of the PHP code:
Seems fairly self-explanatory, right? Heh. Now let's look at the Python version of this:
<sarcasm>Wow, yeah... PHP really does rock! It must be the coolness factor behind the ternary operator they use! The Python code is just horrible compared to the PHP code.
How about the part where you check to see if a credit card number fits the profile of a known credit card? The PHP:
Very eloquent. Let's see how bad the Python looks on this one:
Eek gads!!! It's so obvious why PHP is the language of choice for so many people out there. Python doesn't even have a switch statement, for crying out loud! Inconceivable!</sarcasm>
I'm so glad I was able to escape the grips of PHP.
Comments
Comments powered by Disqus