import tensorflow as tf

def print_all_variables(train_only=True):
    '''
    Print all trainable and non-trainable variables
    '''
    if train_only:
        t_vars = tf.trainable_variables()
        print('[*] printing trainable variables')
    else:
        try:
            t_vars = tf.global_variables()
        except:
            t_vars = tf.all_variables()
        print('[*] printing global variables')

    for idx, v in enumerate(t_vars):
        print('  var {:3}: {:15}   {}'.format(idx, str(v.get_shape()), v.name))
