On Aug 28, 8:43 pm, Anny Mous b1540...@tyldd.com wrote:
It isn't irrational to have a healthy caution towards eval.
Ignorance is never an excuse for stupidity. No caution is needed if
you know how to properly use eval. You can't shoot yourself in the
foot without first pulling the trigger.
r wrote:
On Aug 28, 8:43 pm, Anny Mous b1540...@tyldd.com wrote:
It isn't irrational to have a healthy caution towards eval.
Ignorance is never an excuse for stupidity. No caution is needed if
you know how to properly use eval. You can't shoot yourself in the
foot without first pulling the
I would use the following approach:
Abviously the OP is a python baby noob and casting your irrational
fear (and many others irrational fears) of eval at him is akin to
tales of Chupacabras running a muck in the jungle sucking the blood
from live goats in the twilight hours. I use eval all
On Thu, 27 Aug 2009, Stephen Hansen wrote:
num1 = raw_input('Enter the first number: ')
num2 = raw_input('Enter the second number: ')
op = raw_input('Select one of the following [+-*/]: ')
print 'The answer is: ', int(num1), eval(op), int(num2)
On Thu, 27 Aug 2009, r wrote:
On Aug 27, 10:52 pm, Duke Normandin dukeofp...@ml1.net wrote:
How do I convert the contents of op from a string to an actual
arithmetic operator? eval() does not seem to be the answer. TIA!
Try this..
op = '+'
one = '1'
two = '2'
one+op+two
'1+2'
On Fri, 28 Aug 2009, Ben Finney wrote:
Duke Normandin dukeofp...@ml1.net writes:
Hey
I'm a Python noob
So far so good!
I've written the following:
num1 = raw_input('Enter the first number: ')
num2 = raw_input('Enter the second number: ')
op = raw_input('Select one
En Fri, 28 Aug 2009 01:50:37 -0300, Xavier Ho cont...@xavierho.com
escribió:
On Fri, Aug 28, 2009 at 2:35 PM, Ben Finney
ben+pyt...@benfinney.id.auben%2bpyt...@benfinney.id.au
wrote:
op_funcs = {
'+': operator.add,
'-': operator.sub,
'*': operator.mul,
'/':
r wrote:
Abviously the OP is a python baby noob and casting your irrational
fear (and many others irrational fears) of eval
It isn't irrational to have a healthy caution towards eval.
Apart from the security issues, running code in eval takes a massive
performance hit. Its about ten times
Hey
I'm a Python noob
So far so good!
I've written the following:
num1 = raw_input('Enter the first number: ')
num2 = raw_input('Enter the second number: ')
op = raw_input('Select one of the following [+-*/]: ')
print 'The answer is: ', int(num1), eval(op), int(num2)
On Fri, Aug 28, 2009 at 1:52 PM, Duke Normandin dukeofp...@ml1.net wrote:
How do I convert the contents of op from a string to an actual
arithmetic operator? eval() does not seem to be the answer. TIA!
Maybe you were looking for
print eval(num1 + op + num2) # it's a little ugly string
On Aug 27, 10:52 pm, Duke Normandin dukeofp...@ml1.net wrote:
How do I convert the contents of op from a string to an actual
arithmetic operator? eval() does not seem to be the answer. TIA!
Try this..
op = '+'
one = '1'
two = '2'
one+op+two
'1+2'
eval(one+op+two)
3
you could also use
num1 = raw_input('Enter the first number: ')
num2 = raw_input('Enter the second number: ')
op = raw_input('Select one of the following [+-*/]: ')
print 'The answer is: ', int(num1), eval(op), int(num2)
How do I convert the contents of op from a
Duke Normandin dukeofp...@ml1.net writes:
Hey
I'm a Python noob
So far so good!
I've written the following:
num1 = raw_input('Enter the first number: ')
num2 = raw_input('Enter the second number: ')
op = raw_input('Select one of the following [+-*/]: ')
print 'The answer is:
On Fri, Aug 28, 2009 at 2:35 PM, Ben Finney
ben+pyt...@benfinney.id.auben%2bpyt...@benfinney.id.au
wrote:
import operator
op_funcs = {
'+': operator.add,
'-': operator.sub,
'*': operator.mul,
'/': operator.div,
}
num_1 = int(raw_input('Enter
On Aug 27, 11:35 pm, Ben Finney ben+pyt...@benfinney.id.au wrote:
In general, ‘eval’ on unsanitised input is not the answer.
Yes i agree.
I would use the following approach:
Abviously the OP is a python baby noob and casting your irrational
fear (and many others irrational fears) of eval at
15 matches
Mail list logo