class a: pass f = a() for k in locals().keys(): if isinstance(locals()[k], a): print k This probably isn't what you want. I can't help but wonder what problem you're trying to solve? Maybe this is an area where metaclasses would help? // mark