When using the TensorFlow Python API, I created a variable (without specifying its name in the constructor), and its name property had the value
Based on @mrry 's answer, I think it would be better to create and use the following function, since there's also local variables, and other variables that are not in global variables (they are in different collections):
def get_var_by_name(query_name, var_list):
"""
Get Variable by name
e.g.
local_vars = tf.get_collection(tf.GraphKeys.LOCAL_VARIABLES)
the_var = get_var_by_name(local_vars, 'accuracy/total:0')
"""
target_var = None
for var in var_list:
if var.name==query_name:
target_var = var
break
return target_var