[Python-Dev] features i'd like [Python 3000?] ... #4: interpolated strings ala perl (original) (raw)

Josiah Carlson jcarlson at uci.edu
Thu Dec 7 23:19:58 CET 2006


"Alexey Borzenkov" <snaury at gmail.com> wrote:

It can even be simpler and more powerful:

class evallookup: def init(self, nsg, nsl): self.nsg = nsg self.nsl = nsl def getitem(self, name): return eval(name, self.nsg, self.nsl)

Never use eval in any code where you don't have 100% control of the content of what is being evaluated. And even then, never use eval.

It doesn't make a difference in the earlier example, but I'm sure there are ways of breaking the above in nasty ways.



More information about the Python-Dev mailing list