Re: Newbie question about evaluating raw_input() responses

2013-05-25 Thread Fábio Santos
On 25 May 2013 19:37, "Chris Angelico" wrote: > Ah, who am I kidding. Be as rude as you like. I have to work with PHP all week. > > ChrisA > -- > http://mail.python.org/mailman/listinfo/python-list I have cried. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about evaluating raw_input() responses

2013-05-25 Thread Chris Angelico
On Sun, May 26, 2013 at 4:27 AM, Nobody wrote: > On Thu, 23 May 2013 17:20:19 +1000, Chris Angelico wrote: > >> Aside: Why was PHP's /e regexp option ever implemented? > > Because it's a stupid idea, and that's the only requirement for a feature > to be implemented in PHP. Hey, don't be rude. I m

Re: Newbie question about evaluating raw_input() responses

2013-05-25 Thread Nobody
On Thu, 23 May 2013 17:20:19 +1000, Chris Angelico wrote: > Aside: Why was PHP's /e regexp option ever implemented? Because it's a stupid idea, and that's the only requirement for a feature to be implemented in PHP. -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie question about evaluating raw_input() responses

2013-05-23 Thread Chris Angelico
On Thu, May 23, 2013 at 5:11 PM, Terry Jan Reedy wrote: > On 5/23/2013 12:47 AM, Steven D'Aprano wrote: >> >> On Wed, 22 May 2013 22:31:04 +, Alister wrote: >> >>> Please write out 1000 time (without using any form of loop) >>> >>> "NEVER use input in python <3.0 it is EVIL"* > > >> But all jo

Re: Newbie question about evaluating raw_input() responses

2013-05-23 Thread Terry Jan Reedy
On 5/23/2013 12:47 AM, Steven D'Aprano wrote: On Wed, 22 May 2013 22:31:04 +, Alister wrote: Please write out 1000 time (without using any form of loop) "NEVER use input in python <3.0 it is EVIL"* But all joking aside, eval is dangerous, yes, but it is not "evil". He put that label o

Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Chris Angelico
On Thu, May 23, 2013 at 2:47 PM, Steven D'Aprano wrote: > But all joking aside, eval is dangerous, yes, but it is not "evil". It > needs to be handled with caution, but there are good uses for it. In > fact, there are a few -- a very few -- things which can *only* be done > with eval or exec. That

Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Steven D'Aprano
On Wed, 22 May 2013 22:31:04 +, Alister wrote: > Please write out 1000 time (without using any form of loop) > > "NEVER use input in python <3.0 it is EVIL"* > > as Chris A point out it executes user input an can cause major damage > (reformatting the hard disk is not impossible!) Is he all

Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Kevin Xi
Oh yes, you guys are right. Thank you very much for warning me that. On Thursday, May 23, 2013 6:31:04 AM UTC+8, Alister wrote: > > as Chris A point out it executes user input an can cause major damage > > (reformatting the hard disk is not impossible!) > It definitely can cause major damage

RE: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Carlos Nepomuceno
> From: alister.w...@ntlworld.com [...] > Kevin > > Please write out 1000 time (without using any form of loop) > > "NEVER use input in python <3.0 it is EVIL"* > > as Chris A point out it executes user input an can cause major damage > (reformatting the har

Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Alister
On Tue, 21 May 2013 23:52:30 -0700, Kevin Xi wrote: > On Wednesday, May 22, 2013 2:23:15 PM UTC+8, C. N. Desrosiers wrote: >> Hi, >> > Hi, >> >> I'm just starting out with Python and to practice I am trying to write >> a script that can have a simple conversation with the user. >> > So you may

Re: Newbie question about evaluating raw_input() responses

2013-05-22 Thread Chris Angelico
On Wed, May 22, 2013 at 4:52 PM, Kevin Xi wrote: > On Wednesday, May 22, 2013 2:23:15 PM UTC+8, C. N. Desrosiers wrote: >> age=raw_input('Enter your age: ') >> if age > 18: > > You can either use `raw_input` to read data and convert it to right type, or > use `input` to get an integer directly. R

Re: Newbie question about evaluating raw_input() responses

2013-05-21 Thread C. N. Desrosiers
Muchas gracias! On Wednesday, May 22, 2013 2:35:18 AM UTC-4, Fábio Santos wrote: > You have to convert `age` to an integer. Use int() to do it. Then you can > compare it to other numbers and obtain the expected results. > > On 22 May 2013 07:29, "C. N. Desrosiers" wrote: > > Hi, > > > > I'm

Re: Newbie question about evaluating raw_input() responses

2013-05-21 Thread Kevin Xi
On Wednesday, May 22, 2013 2:23:15 PM UTC+8, C. N. Desrosiers wrote: > Hi, > Hi, > > I'm just starting out with Python and to practice I am trying to write a > script that can have a simple conversation with the user. > So you may want to search the doc before you ask: http://docs.python.org >

Re: Newbie question about evaluating raw_input() responses

2013-05-21 Thread Fábio Santos
You have to convert `age` to an integer. Use int() to do it. Then you can compare it to other numbers and obtain the expected results. On 22 May 2013 07:29, "C. N. Desrosiers" wrote: > Hi, > > I'm just starting out with Python and to practice I am trying to write a > script that can have a simple

Newbie question about evaluating raw_input() responses

2013-05-21 Thread C. N. Desrosiers
Hi, I'm just starting out with Python and to practice I am trying to write a script that can have a simple conversation with the user. When I run the below code, it always ends up printing response to "if age > 18:" -- even if I enter a value below 18. Can anyone point me to what I am doing wr