converting string to dict ?

Andrew Dalke dalke at acm.org
Wed Apr 11 11:26:03 EDT 2001


/F wrote:
>>>> eval("{'name': 'Cleopatra'}", {"__builtins__": {}})
>{'name': 'Cleopatra'}
>
>the __builtins__ stuff is optional, but provides some protection
>from evil data providers:

Note that it isn't full protection.  Consider

  eval("[0] * (2 ** 31)")

which will cause most machines to run out of memory.

                    Andrew
                    dalke at acm.org






More information about the Python-list mailing list