11 March 2016 - Forum Rules

Main Menu


Started by creeperton, October 31, 2014, 01:07:08 PM

Previous topic - Next topic



Gideon Zhi

You're not doing anything with the output from eval. It's evaluating, but because you're not assigning the end result to anything, that result gets lost to the ether. Try something along the lines of:

listName = eval(newList)
print listName

Also, you want to be careful of your PEP8 identifier names.


The result of :
is None. The side-effect is now that my_list contains one more item.

So I guess GideonZhi's code would result in displaying None.

Maybe :

eval('print ' + listName)

Also, newList is a bad name because it's a string, not a list, and it describes a command (so append_cmd would be better).

Kiyoshi Aman

Protip: If you put your lists in a dict you don't have to eval() a damn thing.