21
Week In Links – 8/21/2009
Over the last few weeks I’ve noticed a few things,
- I always have a lot of links open in FireFox that I haven’t looked at yet.
- Blog traffic drops like mad on Fridays
These are just some sites or articles that I found interesting or helped me in some way this week.
So here’s what I have this week! (other posters can add to this page as they wish)
- http://www.infoq.com/articles/agile-version-control
- http://kenai.com
- http://oauth.net
- http://code.google.com/p/modwsgi/wiki/DebuggingTechniques
- http://blog.lowkster.com/2008/01/getting-to-pesky-foreign-key-data-in.html
- http://www.box.net
- http://beanstalkapp.com
- http://www.ducea.com/2006/08/11/apache-tips-tricks-deny-access-to-some-folders
- http://www.fogcreek.com/FogBugz
- http://www.sitepoint.com/article/build-to-do-list-30-minutes
24
# Override decorator
While working with pyglet one day, I made the mistake of subclassing the window class and overriding the __init__ method, which prevented the window from showing. To fix this, it’s easy enough to add a call to super(Window, self).__init__(*args, **kwargs), but I went a different route. Here’s a decorator called override that puts it in for you:
def override(function):
def wrapper(instance, *args, **kwargs):
super(instance.__class__, instance).__init__(*args, **kwargs)
return function(instance, *args, **kwargs)
return wrapper
To use it, simply use the decorator notation in a subclassed method:
class MyWindow(pyglet.window.Window):
@override
def __init__(self, *args, **kwargs):
# code goes here, no need to call super!
10
# Function/Method Decorators
One of the reasons I like Python is because it’s simple but powerful. All the tools are there for whatever task needs to be done. I’ve found __getattr__ to be a very useful tool for creating sets of standardized class methods without having to explicitly declare them. Another useful tool is function decorators. Read on to get a quick idea of how to make your own class decorators.
9
# __getattr__ Deserves Some Respect
One of Python’s built-in functions is __getattr__, which turns out to be quite useful but at the same time slightly dangerous. It is especially helpful for creating complex classes without using inheritance. For a brief tutorial, read on.
25
# Python Dictionary Coolness
Lately I’ve been working with dictionaries, specifically as a device for storing settings. I ran into a little annoyance and thought of programming a little routine to take care of it. Come to find out, Python already has such a routine built into the dictionary class. Read on to find out more.
10
Python Scripting within a Python Script
UPDATE: In order to use reload in Python 3, it must be imported from the imp built-in module. Thus, some of the examples below will require the line from imp import reload in order to work in Python 3.
I’ve been mulling over an idea for a little while now, but didn’t have the chance to do anything with it until today. Turns it it was way easier than I thought it would be. For reasons I won’t go into here, I wanted to have a Python program which could write and run other Python programs. Clearly Python can write programs (since it can save text as a .py file), and it can easily run programs just by importing a module. The trouble was editing those files and running the updated code in the master program without having to restart the master program. Here’s how I did it.

