lazyweb code review

I’m writing a tool in python that will automate the posting of the weekly newsletters for the film club. Currently, I manually post to LiveJournal, Craigslist, the SNFC webpage, and the mailing list. I had a tool a long time ago but it broke for various reasons.

Anyway, I want to have a directory of .py containing classes, and call a method [execute()] on each of them. This way I can just create a new subclass, pop it in that directory, and it will be picked up automatically. This is what I came up with, somehow I feel it’s crude and there is a better way to do it (ignore bad var names pls):

plugins = glob.glob("plugins/*.py")

for x in plugins:
pathName = x.replace(".py","")
className = x.replace(".py","").replace("plugins/","")

foo = __import__(pathName,globals(), locals(), [''])
bar = getattr(foo,className)

obj = bar()

obj.execute(nl)

This code looks for all of the .py files in the dir, imports them, gets the class from the imported module, and instantiates them. Finally, it calls the execute() method. Any suggestions?

It’s friday, i’m in Rochester

Went to my morning class today, in the snow, and let me tell you, it was well worth it. That class is like novocaine for your mind. Jon is still in bed; I have been trying to be quiet as to let him rest as best as he can, but I am sure that I have unsettled him.. Not much I can do about that…

I have been working on a python module for interacting with drink. Part of reason is that Jon hasn’t been able to get PHP to do sockets right under Solaris (I don’t think it is a high priority for him), and I want a web client for Drink. The other reason is because I wanted to learn the language beyond my fundamental understanding that I had gleaned from seminars at CSH. It is a neat language, and far better than perl, but I don’t see myself using it for some of the more wack uses (like GUI programming).