As noted by R Nar, there are ways, and hopefully this will help you. You can make use of the inspect module to interrogate frames of reference and the calling stack of you application. I haven't stress tested this code, so can't guarantee the amount of runway you will have with it. Hopefully enough! One that that I can be sure of, is that depending on your specific Python implementation, inspect.currentframe() may not be available. I have tested this on standard CPython, 2.7.10.
You will need to create a function that is accessible where you need it:
def print_variable(variable_name):
import inspect
frame = inspect.currentframe()
try:
value = frame.f_back.f_locals[variable_name]
print variable_name, "-", value
except KeyError:
print variable_name, "does not exist!"
finally:
del frame
The use of the frame and frame.f_back allows you to examine the frame of the calling function (dangerous of course!) and grab the variable's value from the locals of that frame, with f_locals.
As a sidebar, for the reasoning behind the del frame is due to preventing cyclic reference counting that would prevent the garbage collector from deleting the frame object. If you interested in that, take a look here.
This function will rely on you passing the variable you wish to print, by passing the string for its name. Will that get you where you need, or do you want to be able to pass the variable itself (not as a string)?
>>> my_var = '123'
>>> print_variable('my_var')
'123'