"Alexey Borzenkov" <[EMAIL PROTECTED]> 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.

 - Josiah

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to