[Tutor] What's in a name?

Mark Lawrence breamoreboy at yahoo.co.uk
Fri Jan 3 06:51:29 CET 2014


On 03/01/2014 05:29, Keith Winston wrote:
> Hmm, maybe I stumbled upon at least one approach, turning the problem
> around. Make it something like:
>
> for i in ["alist", "blist", "clist"]
>      i[3] = "okey dokey "
>      print(eval(i)[3], i)
>
> Of course I've been staring at this for a while, but as soon as I post I
> find a way... this is my first use of eval(), so it took me a while to
> stumble upon it. If there are more elegant solutions, I'm all ears.
>

Your code is still invalid.  I still don't understand what you're asking 
for.  I've never used eval in over 10 years of using Python, here's why 
http://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html

-- 
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.

Mark Lawrence



More information about the Tutor mailing list