Wednesday, August 4, 2010

Recent work

I would now consider myself firmly wedged in the "Intermediate" category of python programming.  I have come a long way, but have a ways to go.  Some of the recent highlights are that it has become much easier to envision how to achieve a small task and how to complete these smaller tasks in many different ways.  On the other hand, I feel that I am constantly writing things the same way:
Define variables
Import files to work on, create files to write to
Some sort of transformation (almost exclusively a for loop)
Write out results and save file

I know that there are better ways to do this (such as use a generator instead of appending to a list) but its taking a while to figure out how to do that.  Its a bit frustrating to replace the speed at which I was able to read through books and work on earlier projects to now having to feel like I am plodding along.  But I guess thats life with programming (and other problem solving strategies).

Wednesday, June 30, 2010

Beginning Python Visualization

book review: Beginning Python Visualization

In my quest to learn enough python to sufficiently learn to write a sudoku solver, I have also made it my quest to finish all of the Python books that have been lying around my apartment half-finshed for months if not years.  This book is one of those.  And its a shame it took me so long because I really enjoyed this book.  The title of the book is a bit misleading because only small parts of it are actually about visualization and the majority seemed to be real-world uses of python.  Still, that is realevant and I learned a fair amount about processing text files and data organization.  The bulk of the visualization covers PIL and matplotlib.  As someone coming from an R background, the dynamic nature of matplotlib was like a breath of fresh air compared to the more static standard R plot.  The book was full of lots of seemingly unrelated items (the last chapter was pretty much only random items) and most of these were pretty interesting/relevant such as Magic Squares.  I am curious to play around with magic squares and hope to return to it in a later post.

Saturday, June 12, 2010

Learning Python by O'reilly

After too many years to think about, I finally finished reading Learning Python by Lutz & Ascher from O'Reilly media. I picked up the second edition a few years ago and had been reading that. Currently the book is on its 4th edition and comes in at a whopping 1216 pages (mine was only 590 p.) At that many pages, the 4th ed. might be better called the Python Compendium or something more appropriate to its length. That much in a book titled 'Learning' would definitely scare me off entirely.

Anyways, the book is in its 4th edition for a reason, its very comprehensive and well written. I felt that the material was presented in a fairly straightforward manner and it was well-indexed (always a sign of a good book). The only minor issue I had was with the examples, some of them were quite obtuse especially when given the subject material they were deisgned to test. As a whole I found it to be an excellent book and it will be a great desktop reference in the future.

Tuesday, June 8, 2010

overall layout

So I am not so sure how enthralled I am about the overall layout there on blogger. I chose this theme because it was the most python-like motif-wise (ehh double hyphen, not sure what Strunk & White would think of that). As I look at it the blog looks a bit cluttered and I am not sure if I like the posts so close to each other.

I may start looking at alternative options soon...

Monday, June 7, 2010

Learning Python The Hard Way

Over the weekend, I finished working through Learning Python the Hard Way by the outspoken Zed Shaw. His eventual goal for the book is to cover 52 exercises in all, and so far the first 26 are compiled together in a pdf and cover just input/output, variables, and functions. Hopefully the next 26 will be published soon, although those who can't wait can read what he has written online (currently at Lesson 38).

I really enjoyed this book and thought it had a great combination of good examples and good writing. For example:
"""Every programming language has some kind of way of doing numbers and math. Don’t worry, programmers lie frequently about being math geniuses when they really aren’t. If they were math geniuses, they would be doing math not writing ads and social network games to steal people’s money."""

The code itself is good, although I did find myself tweaking it a bit to fit my style (or what I think it should look like). For example, he frequently passes multiple variables to argv and its evident that this is causing issues with some (and yes that is me commenting). However as a whole I am enjoying it and looking forward to the second half being printed.

Friday, June 4, 2010

Stack overflow

I just added my SO account widget. I have found SO to be immensely helpful in learning more about python. Yesterday, I was able to directly use what I casually read on SO to solve a problem I have been having comparing lists. By importing two lists of rs numbers in text files I was able to use set.difference() to compare the lists and find differences. Very helpful when one of the lists was ~900K lines.

Tuesday, June 1, 2010

A bit of background

A bit of background about me. I picked up Learning Python version 2 (now covering Python 2.3!) a few years ago and probably could have written "hello world!" and maybe made a list but that's about it.

I work in a research institution and dealing with large-scale sequencing data has forced me to re-visit python to be able to better manage sequence output files. Currently I can push things around and write some basic loops but still feel I am a beginner who experiences my fair share of exceptions and errors.

I hope to make later posts reviews of various books and articles I have read about python that may or may not have been helpful to me.