Skip navigation

Category Archives: Python

Stories tagged ‘Python’

Python FTGL Bindings

I’ve just released PyFTGL which makes it possible to take advantage of FreeType and FTGL to render text in OpenGL program using TrueType, Type 1 or OpenType fonts. PyFTGL wraps the functionality of FTGL into a Python module so it can be used in conjunction with PyOpenGL.

Note that the bindings are still in alpha: they will work if you use them correctly, it’s just the error checking that’s currently missing.

Last.fm Radio Protocol

During the weekend I decided to hack together my own last.fm radio player in Python. I had found the My Playlist station pretty useless after being treated to the same three songs over and over again, and set out to code a player that would autoskip any songs I’ve already listened to once during a “session”.

So I combed the web and the official developer forum for useful information and even ended up digging into the official desktop client source code to find the answers to my questions. All information needed to implement a client (bar already officially documented components) have now been compiled into one spec-like entry in my last.fm journal.

import time as summer

Python Not many new posts have showed up here in a while due to the fact that a) I have nothing web or code worthy to say and b) I have been busy getting my native Swedish blog going.

But don’t despair. During my summer break this year I’ve started to code a new application in Python that I’m hellbent on completing and releasing. In the process I’m thinking about writing up some brief pythonic posts on topics I usually revisit (or relearn) every time I get back to code in Python. On the joy of Python.

That Python Is Strangling Me!

I’ve given up on implementing Python classes using C API since I couldn’t get instancing in the C API to work properly. No helpfull error messages, either segfault or “wrong arguments in Objects\classobjects.cpp line 504″, no helpfull documentation, and me to tired to even type gdb. I’m going back to write a simple module and wrap it in classes written in Python.

But that solutions annoy me because it will mean I first write a module, transfering my C++ interfaces to something similar to a C interface (object-oriented non the less in a GTK+ way), and then wrap that module into Python classes miming the original interfaces. I had hope to shorten that path. But apparently failed to do so. Oh well, oh well… There’s another day tomorrow, said Scarlett O’Hara before she logged of.

And Now Something Completely Different …

I finally figured out how to implement classes in Python using C API — the right way. Namely as a new type using the PyTypeObject complete with get and set attribute calls and plain members. But I tought my previous hack for building a class at runtime is still slim enough to share, especially if you just got a couple of methods that you want bundled into a class instead of a module.

Read the full story

Creeper