Archive for October, 2012

Check iO: A game where you code in Python

October 30, 2012 Leave a comment

Check iO is a browser-based game where you need to solve problems in Python in order to advance.


Update (20121109)
Guido found it too :)

Categories: python Tags: , ,

Determine the name of the current function

October 24, 2012 Leave a comment

You want to determine the name of the current function.


import sys

def whoami():
    print '# this function is:', sys._getframe().f_code.co_name
    print '# this line number is:', sys._getframe().f_lineno
    print '# this file\'s name is:', sys._getframe().f_code.co_filename



# this function is: whoami
# this line number is: 5
# this file's name is:

Also, by calling sys._getframe(1), you can get this information for the *caller* of the current function. So you can package this functionality up into your own handy functions:

import sys

def get_function_name():
    return sys._getframe(1).f_code.co_name

def whoami():
    func_name = get_function_name()
    print '# current function\'s name:', func_name



# current function's name: whoami

This tip is from here.

Building Skills in Python

October 8, 2012 Leave a comment

I found a freely available Python book at Linuxtopia called “Building Skills in Python“.

This Linuxtopia site is great! Check it out!

Categories: python, ubuntu Tags:

How to Write a Spelling Corrector

October 8, 2012 Leave a comment

See Peter Norvig’s post.

You can also check out his site.