Python – Get current function and parent function

When troubleshooting a fairly complex Python script I tend to find it a massive headache when working out the flow of the functions. What function am I currently in? What function called it etc. Looking through theĀ docs I finally discovered the inspect module.

By making the following two functions;

def returnFunction():
return inspect.stack()[1][3]
def returnParent():
return inspect.stack()[2][3]

I can now call these from within my logger.debug lines and output the current function and parent function (the one that called the current function), all as soon as it executes.

An example;

logger.debug(“currentFunction=\”%s\” parentFunction=\”%s\””,returnFunction(),returnParent())

Read More

Reprisal – Web based indie game

So I discovered this cool game called Reprisal yesterday thanks to Rock, Paper, Shotgun.

Reprisal the game screenshotIts a cool little pixel, web browser based game thats been built with games of old like Populous in mind. Basically its a god game where you shape terrain to get your little tribal guys to fight the enemy, win territory, build villages and harvest resources.

The only requirement is a web browser! (And flash) Go try it out now and let me know what you think, I’m only up to level three but its pretty fun having a game like this available at the click of a bookmark.

UPDATE: There is now a desktop version available for Windows and Mac! (You just need to have Adobe Air installed). Don’t forget to give the developer a donation, the game might be free but the time he put into it wasn’t and its definitely worth paying for.

ANOTHER UPDATE: It is now also available on Linux via the Desura distribution system which is great news for people wanting to play this game offline on their *nix machines! Make sure you go check it out, NOW!

Read More