Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44656 > unrolled thread
| Started by | "dabaichi" <valbendan@outlook.com> |
|---|---|
| First post | 2013-05-03 15:16 +0800 |
| Last post | 2013-05-03 17:31 +1000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.python
python2 input "dabaichi" <valbendan@outlook.com> - 2013-05-03 15:16 +0800
Re: python2 input Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-05-03 07:29 +0000
Re: python2 input Chris Angelico <rosuav@gmail.com> - 2013-05-03 17:31 +1000
| From | "dabaichi" <valbendan@outlook.com> |
|---|---|
| Date | 2013-05-03 15:16 +0800 |
| Subject | python2 input |
| Message-ID | <klvo0t$2blv$1@adenine.netfront.net> |
Hello guys:
Do you have found that the built-in input() function is dangerous.
Here is my code(python 2.x only):
a = input("Input anything:")
print("go here")
If I input:
sys.exit(0)
print("go here") will not be execute, and the script will exit.
--- news://freenews.netfront.net/ - complaints: news@netfront.net ---
[toc] | [next] | [standalone]
| From | Steven D'Aprano <steve+comp.lang.python@pearwood.info> |
|---|---|
| Date | 2013-05-03 07:29 +0000 |
| Message-ID | <51836774$0$29997$c3e8da3$5496439d@news.astraweb.com> |
| In reply to | #44656 |
On Fri, 03 May 2013 15:16:09 +0800, dabaichi wrote: > Hello guys: > Do you have found that the built-in input() function is dangerous. Correct. Use raw_input instead. -- Steven
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-05-03 17:31 +1000 |
| Message-ID | <mailman.1264.1367566322.3114.python-list@python.org> |
| In reply to | #44656 |
On Fri, May 3, 2013 at 5:16 PM, dabaichi <valbendan@outlook.com> wrote:
> Hello guys:
> Do you have found that the built-in input() function is dangerous.
> Here is my code(python 2.x only):
>
> a = input("Input anything:")
> print("go here")
>
> If I input:
> sys.exit(0)
> print("go here") will not be execute, and the script will exit.
Yeah, that's kinda discovered. In Python 2, you should be using
raw_input() for that kind of thing. In Python 3, raw_input() was
renamed to input(), and if you want the semantics of Py2 input(), it's
eval(input()), which makes it obvious what's going on.
ChrisA
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web