How about a function you can call? This function accesses the caller's frame, and rather than using locals(), uses frame.f_locals to get the caller's namespace.
def my_function():
frame = currentframe().f_back
msg = 'We are on file {0.f_code.co_filename} and line {0.f_lineno}'.format(frameinfoframe)
current_state = frameinfoframe.f_locals.items()
print current_state['some_variable']
Then just call it:
def some_function:
my_function()
def some_other_function:
some_function()
my_function()
class some_class:
def some_method:
my_function()