Wednesday, September 17, 2008

Still can't figure out decorators

After a couple months (roughly) of Python programming, I'm very happy with how far I've come and what I'm able to accomplish. When all this started my biggest struggle was the basic object-oriented programming mindset. After further study and a good bit of trial and error, though, I feel I've got a pretty good handle on it. I'm not a whiz by any stretch, but I'm a lot more comfortable with it now than I was when this all began.

That leads me to the next programming concept I'd like to grok: decorators.

I just stumbled across a blog post in which the author claims that Python's decorators are "radically simple." I'm sorry, but I've read a good number of explanations behind decorators -- including the Wikipedia article on the subject, which includes a pseudo-example in Python -- and this "radically simple" outline (i.e. the slides that Mr. Diederich used in his PyCon UK talk) hasn't made the concept any clearer for me.

Does anyone know where I can find a truly clear description of Python decorators? Perhaps this is something that could be more easily understood if I had a solid computer science background instead of an animator-who-fell-in-love-with-programming-on-the-side background.


Saturday, September 13, 2008

iPod Touch vs. the clock

I noticed recently that my iPod Touch wasn't syncing its date and time properly with the computer. At first I thought it might be a glitch in the Touch software, so I experimented by syncing several times in a row to see if I could find a pattern. The only pattern I noticed was it gave me a different time (and I assume a different data) with each sync: 1:24 AM, 4:11 PM, 9:18 AM, etc.

A quick Google search led me to a thread that outlined the true source of the issue: iTunes. If you put your computer to sleep with iTunes open, and then try to sync the iPod Touch after waking it up, iTunes appears to invent a random date and time to send to the device. To avoid this, simply close and re-open iTunes before syncing.

Friday, September 12, 2008

Python and list copies

While working on a tool at Reel FX, I couldn't figure out why the data lists across several different class instances were all returning the same information. Normally working with lists in Python is tons-o'-fun (especially when compared to the gymnastics required to do similar operations in MEL), but that fun can come to a screeching halt if you forget one little important detail: copying a list doesn't necessarily copy the list.

For example, say there's a list assigned as follows:
   data = ["apples","oranges","pears"]
Some time later you want stuff to be a copy of data:
   stuff = data
If you've come to Python with some previous programming/scripting experience, you might assume (as I've done more than once) that this would do the trick. However, that just tells stuff to reference the list assigned to data. If you end up changing data later on, and then look at stuff, you'll notice that it shows the same changes. That's because they're both pointing to the same list in memory.

So how does one get around this little annoyance? Pretty simply, actually:
   stuff = data[:]
That bit on the end tells Python to make stuff equal to the entire contents of data, instead of making it just another pointer. To be more accurate, it duplicates the list to which data is pointing, and then points stuff to that new list.

Dictionaries also exhibit this same point-instead-of-copy behavior, but the syntax is different if you want to make a true copy:
   newdict = olddict.copy()
(Pardon the crazy formatting. I've never tried to insert code blocks into a blog post, and getting it to look decent with the controls available in the Blogger editor is driving me nuts. Methinks it's time to consider an alternative blogging system...)

Saturday, September 06, 2008

Open Season 2 trailer

Pop on over to the Reel FX web site to take a look at the first trailer for Open Season 2. I think it was a little over a year ago when we animated the test for Sony, we started working on cycles in October, and primary animation ran from early November through June/July of this year. Even with the initial animation stress mentioned in an earlier post, the overall project went very smoothly, with very little overtime, and everyone did an outstanding job. From what I understand, it'll hit shelves around January of '09.

Tuesday, September 02, 2008

RIP Don LaFontaine

The man known by many in the voiceover industry as "the voice of God" has returned to the one who lent the voice. Don LaFontaine died on September 1st at the age of 68, following a rocky battle with a collapsed lung and subsequent complications. I never had the privilege of meeting Don, but those who have speak of him as the most humble of men and a willing mentor, despite his place at the pinnacle of the voiceover industry.

Rest in peace, Don.