[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: newbie question
From:       Grant Edwards <invalid () invalid ! invalid>
Date:       2016-03-24 15:05:30
Message-ID: nd0vnq$jik$2 () reader1 ! panix ! com
[Download RAW message or body]

On 2016-03-24, Steven D'Aprano <steve@pearwood.info> wrote:
> On Thu, 24 Mar 2016 09:49 pm, David Palao wrote:
>
>> Hi,
>> Use "eval":
>> s = "(1, 2, 3, 4)"
>> t = eval(s)
>
> Don't use eval unless you absolutely, categorically, 100% trust the source
> of the string.

And then still don't use it. :)

eval is only safe if you're passing it a literal string containing
nothing but a literal constant expression -- in which case the eval is
superflous.

OK, I admit I've used it for quick hacks on occasion.  But, I
shouldn't have.

-- 
Grant

-- 
https://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic