Re: How is correct use of eval()

2010-10-12 Thread Hrvoje Niksic
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

Re: How is correct use of eval()

2010-10-12 Thread catalinf...@gmail.com
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

Re: How is correct use of eval()

2010-10-11 Thread Nobody
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

Re: How is correct use of eval()

2010-10-11 Thread Chris Rebert
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

Re: How is correct use of eval()

2010-10-11 Thread Nobody
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

Re: How is correct use of eval()

2010-10-11 Thread Steven D'Aprano
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()

Re: How is correct use of eval()

2010-10-11 Thread Robert Kern
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

Re: How is correct use of eval()

2010-10-11 Thread Chris Rebert
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

How is correct use of eval()

2010-10-11 Thread Cata
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? Thank's -- http://mail.python.org/mailman/listinfo/python-list