I think it easier to explain with an example, so here it goes: Assuming there's a function fn that does what I want, it would work like this: g = 23 foo = {'a':56} fn(g) => 'g' fn(foo) => 'foo' How can I write fn? O:-)