Thursday, April 24, 2008

"raise" becomming a function in py3k?

Over on the voidspace blog, there is a little discussion about raising an exception in a lambda.

Because raise is a statement, it's kind of a hard thing to do. Raising an exception as an expression that is.

Which "raises" the question, why isn't raise a function in py3k?

The two suggestions on how to raise in an expression were these:
>>> r = lambda: eval(compile("raise RuntimeError", '', 'exec'))
>>> r()

>>> ctypes.pythonapi.PyErr_SetObject(*map(ctypes.py_object, (e.__class__, e)))

Which are kind of both a bit yuk.

So maybe raise could be a bit more expressive in py3k?

Wednesday, April 23, 2008

Bars in Beijing?

A friend of mine who lives in Beijing has set up a website categorising all the Bars in Beijing.

It's still a work in progress, but he has listed over 500 bars so far. For a place as big as Beijing, you can imagine that there's going to be a lot of bars. They're categorised by location, and if they are a night club, a bar, or a KTV(karaoke) place etc.

He still wants to add photos for all of the bars, and just generally make it a nice guide to Beijing bars.

Tuesday, April 15, 2008

Ludumdare 48h game development competition this weekend.

For those that didn't have time for pyweek (like me) - there is the ludumdare game development competition.

The ludumdare competition is similar to pyweek - it's what inspired pyweek.

The main differences are it's more "from scratch", it is only one weekend, and you have to do everything yourself - no teams. Also you can use any language - not just python, and everyone can select themes over three voting rounds.

The main idea is that One has to do all parts of game development - art, coding, sound, music etc, and to concentrate on the design of the game - rather than building engines. So it's a short burst of creativity, and junk food eating - with around 100 other people at the same time making their own games.


(img by MrFun).


LD 11 :: Weekend of April 18-20 - Currently doing round 2 of theme voting.

Tuesday, April 08, 2008

database ORM adaptors?

Are there any adaptors for the various python database ORM models?

For example SQLObject <-> Storm <-> mother ORM <-> django ORM <-> SQLAlchemy <-> GeniusSQL, etc.

It seems this might be a good way to reuse some models, and code for those models.

For example, say there was a SQLAlchemy <-> Django ORM adaptor, then pylons, django, and turbogears could more easily inter operate.

Then if an adaptor for SQLObject <-> SQLAlchemy was made SQLObject could then use the SQLAlchemy <-> django ORM adaptor.

I guess at this point, sharing at the database level makes more sense.


update: http://code.google.com/p/django-sqlalchemy/ seems to be a work-in-progress "project to create SQLAlchemy mapping of Django models onto a SQLAlchemy backend".

Wednesday, April 02, 2008

Being proactive with bugs - search, not categorise.

I like to search for bugs, not so much wait for them to be reported in one specific way. Here's a story to illustrate what I mean.

As part of a new pygame release we've been improving the pygame bug reporting, and fixing system.

The old(and current) system used the mailing list as a bug reporting system. We still use this system, but have added a few other methods. People simply report bugs and patches to the mailing list. Then developers search through the mailing list, and noted when they were fixed, on the mailing list. Because the pygame mailing list is quite large often a lot of people would view, review and fix the bugs. It also informs people how to report a bug - because people on the mailing list see it happening every now and then.

Having bugs in the mailing list is nice, because I can type BUG into my mail programs search function to find bugs. Or I can type PATCH to find patches. Or I can have my program filter emails with bug, patch from specific mailing lists to bug, and patch folders. When a bug is fixed, or people want to discuss it, you can just tell them in the email.

Some times people also email me directly about bugs - which is pretty easy if they don't want to join the mailing list, or put it into a bug tracker. People also leave bug reports in our web based documentation commenting system - and not only documentation bugs.

However bugs often got reported in all sorts of other weird places. People talk about bugs in OS distribution bugzillas, random blogs, and also random forums. As well as people talk about bugs on irc. There are also SDL specific bugs reported in their bugzilla (pygame depends on the Simple DirectMedia Layer).

So rather than waiting for people to submit their bugs in a particular way - we now go and search for them too. On the pygame bug page, I have collected together a selection of links to different OS specific bug trackers. So it's easy to see how the OS distribution specific bugs are going. (ps freebsd, and gentoo have been the best updating their packages of pygame to version 1.8 so far).

Searching for bugs, rather than waiting for people to report them, and categorise them is the way to go. Luckily we have search engines which can search the internet for bugs easily.

So now, rather than typing BUG into my mail program, I can type it into a general search engine. Since mailing lists, bugzillas, forums, and blogs are all mostly indexed - my searches for bugs and patches work just fine.

We also have a web based bug tracker - a pygame bugzilla - for those who like to file bugs away in a database. Since some people prefer to submit, and track bugs that way.

update: This World of Reuse blog post asks if this proactive approach to bugs is scalable for larger more widely used projects like firefox. I commented on the blog how it could be added to any sized project, but the comment is still in the moderation queue. I found the world of reuse blog post with my "pygame bug" searching.