John J. Lee wrote:
"Adomas" <[EMAIL PROTECTED]> writes:
Well, a bit more secure would be
eval(expression, {'__builtins__': {}}, {})
or alike.
Don't believe this without (or even with ;-) very careful thought,
anyone. Google for rexec.
John
This module provides a more systematic way to set up res
"Adomas" <[EMAIL PROTECTED]> writes:
> Well, a bit more secure would be
>
> eval(expression, {'__builtins__': {}}, {})
>
> or alike.
Don't believe this without (or even with ;-) very careful thought,
anyone. Google for rexec.
John
--
http://mail.python.org/mailman/listinfo/python-list
Well, a bit more secure would be
eval(expression, {'__builtins__': {}}, {})
or alike.
--
http://mail.python.org/mailman/listinfo/python-list
Michael Hartl wrote:
> Adam brings up a good point: eval is a very general function which
> evaluates an arbitrary Python expression. As a result, it (and its
> close cousin exec) should be used with caution if security is an issue.
To get a secure eval for simple mathematical expressions, it sho
Adam brings up a good point: eval is a very general function which
evaluates an arbitrary Python expression. As a result, it (and its
close cousin exec) should be used with caution if security is an issue.
Michael
--
http://mail.python.org/mailman/listinfo/python-list
On Sat, 2005-02-05 at 17:11, Michael Hartl wrote:
> Use the eval function:
>
> >>> eval("30/(6+9)")
> 2
>
> Michael
Sure, if you trust the source of the string you are evaluating. If this
is a form submission on your web site, be wary of the nefarious user who
might submit to you:
commands.get
On Sat, Feb 05, 2005 at 02:11:07PM -0800, Michael Hartl wrote:
> Use the eval function:
>
> >>> eval("30/(6+9)")
> 2
>
Thanks, just what I was looking for!
--
http://mail.python.org/mailman/listinfo/python-list
Use the eval function:
>>> eval("30/(6+9)")
2
Michael
--
http://mail.python.org/mailman/listinfo/python-list
Hello, I need to convert a string to a number, but the string can
contain +,-,* and / as well as parenthesis. For example, if I have the
string "30/(6+9)" I would like a function that returned the number 2.
I actually wrote a java function that did this a couple of years ago, in
school, as an e