Tag: Python
Why I’ve fallen in love with Python
by Seth on Jul.27, 2009, under F/OSS, Python
In a previous post, I briefly mentioned falling in love with Python. Now that I’m finally using Python for a large percentage of my development and am more than “casually acquainted” with its toolset, I thought it would be fun to highlight a few reasons why Python has become my new language of choice.
In an effort to help you understand where I’m coming from, let me (briefly) rehash some of my programming history: I spent much of the 90’s doing dynamic web development using Perl (weren’t those the days!). I eventually migrated to PHP which usually made things much easier on the web; and subsequently replaced most of my console scripting with BASH [shell scripting]. However, I’m kind of a hack and love languages so I have occasionally been known to write something in C; and although I’m not a complete stranger to Java and Ruby, I never really felt like I “clicked” with either of those languages.
Ok, now that I’ve hopefully convinced you that I’m not just a fly-by-night programmer, let me show you some Python code. Brace yourself, as this article is bound to get lengthy… (continue reading…)
Making TurboGears and Authorize.net play nice together
by Seth on Jul.18, 2009, under Python, Web Development
I recently had to wire up an Authorize.net form for a TurboGears project I’m building, and since I’m a bit new to custom form validation in TG I had quite a bit of trouble figuring out the “right” way to do it.
The goal was to get the form to go through two layers of validation before passing:
- Use the validation packages provided by TG (tw.forms and formencode)
- If the first layer of validation passes, try to run the authorize.net charge. If this returns a response code of 1 (approved) then all validation has passed. Otherwise, invalidate the form and flash the authorize.net error.
tw.forms and formencode are awesome packages, but at first glance there didn’t seem to be “one obvious way” to do things. I found the documentation and tutorials to be scant at best, and eventually went to the TurboGears mailing list for help. In spite of the fact that I’d probably give TurboGears a “C” at best for its documentation (not to mention the availability of “verbose” tutorials), the folks on the mailing list and IRC channel (when it’s actually active) seem to be quite helpful.
Eventually (and with additional help from Google’s source code search) I was able to hack together something that worked as planned, and was overjoyed to observe chained validators in action. Below is some example code provided for your hacking pleasure. To download the full example file, see the links at the bottom of the post. (continue reading…)
Introducing TurboGears 2
by Seth on Jun.09, 2009, under Python, Web Development
I’m the type of person who is a bit anal about trying to use what I think is “the right tool for the job.” This is something I think my Dad passed down to me (I can’t tell you how many times I was scolded with that phrase as a kid—usually having something to do with me trying to hammer an object with anything but a hammer); and it influences my world of development heavily. Because of this, I often find myself using a number of different programming languages and technologies at any given time for various projects. A shell script is perfect when you need something quick & dirty. PHP makes adding logic to HTML a piece of cake. And then there’s my new personal favorite: Python.
Ok, let me back up before I get ahead of myself… (continue reading…)