Hi, I am working on a script where I need to use a lot of aux commands for printing content of a list or a dictionary like this:
my_list = [1,3,5,2] .................................... print "len(my_list) = ",len(my_list)," my_list = ",my_list # or (alternatively): # print "len(my_list) = "+str(len(my_list))+" my_list = "+str(my_list)
So it is needed to repeat (copy-paste or type) 4 times the name of the list/dict I am interested in… I thought if I have a function to tell me list’s name, I can use a much simple procedure with just 1 name of that list such as:
def Output_data(lst): lst_name = Get_Name(lst) # pseudo code - a function that gives me list's name in the script print "len("+lst_name+") = "+str(len(my_list))+" "+lst_name+" = "+str(lst)
Obviously, in the code above, lst_name needs to be a string.
But I dont know how to achieve this… :eek: