Nobody writes:
> Oh, look what's "new in version 2.6":
>
> > ast.literal_eval("7")
> 7
> > ast.literal_eval("7") == 7
> True
Note that it doesn't work for some reasonable inputs involving unary and
binary plus, such as "[-2, +1]" or "2+3j". This has been fixed in the
dev
Ok,
I asking that to understand the correct way of python and I don't want
make mistakes.
I suppose has many tricks used by "bad guys".
--
http://mail.python.org/mailman/listinfo/python-list
On Tue, 12 Oct 2010 01:26:25 +0100, Nobody wrote:
>>> What is correct way to use this function?
>>
>> To not use it in the first place if at all possible (use int(),
>> float(), getattr(), etc. instead,
>
> Use read(). Oh wait, Python doesn't have that. Because parsing literals
> and executing c
On Mon, Oct 11, 2010 at 5:26 PM, Nobody wrote:
> On Mon, 11 Oct 2010 11:18:37 -0700, Chris Rebert wrote:
>>> What is correct way to use this function?
>>
>> To not use it in the first place if at all possible (use int(),
>> float(), getattr(), etc. instead,
>
> Use read(). Oh wait, Python doesn't
On Mon, 11 Oct 2010 11:18:37 -0700, Chris Rebert wrote:
>> What is correct way to use this function?
>
> To not use it in the first place if at all possible (use int(),
> float(), getattr(), etc. instead,
Use read(). Oh wait, Python doesn't have that. Because parsing literals
and executing code
On Mon, 11 Oct 2010 11:18:37 -0700, Chris Rebert wrote:
> On Mon, Oct 11, 2010 at 11:11 AM, Cata wrote:
>> Hi .
>> I read about eval().
>> I also read about this "bug" :
>> cod = raw_input ('Enter:")
>> eval (cod)
>> if i use "rm -rf ~" all files will be deleted .
>
> That's incorrect. eval()
On 10/11/10 1:11 PM, Cata wrote:
Hi .
I read about eval().
I also read about this "bug" :
cod = raw_input ('Enter:")
eval (cod)
if i use "rm -rf ~" all files will be deleted .
What is correct way to use this function?
There are cases when you are writing meta-programming tools for programmer
On Mon, Oct 11, 2010 at 11:11 AM, Cata wrote:
> Hi .
> I read about eval().
> I also read about this "bug" :
> cod = raw_input ('Enter:")
> eval (cod)
> if i use "rm -rf ~" all files will be deleted .
That's incorrect. eval() does not (directly) run shell commands. It
does evaluate arbitrary Py