Hi,
I want to accept the user's answer yes or no.
If I do this:
answer = input('y or n?')
and type y on the keyboard, python complains
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<string>", line 0, in ?
NameError: name 'y' is not defined
It seems like input only accepts numerals, or strings with quotes.
Need solutions, thanks. 8 1914
Use raw_input instead. It returns a string of whatever was typed. Input
expects a valid python expression.
Devan L wrote: Use raw_input instead. It returns a string of whatever was typed. Input expects a valid python expression.
Who actually uses this? It's equivalent to eval(raw_input( prompt)) but
causes a lot of newbie confusion. Python-dev archives revealed that
someone tried to get this deprecated but Guido disagreed.
--
Michael Hoffman
On Thursday 14 July 2005 07:00 am, Michael Hoffman wrote: Devan L wrote: Use raw_input instead. It returns a string of whatever was typed. Input expects a valid python expression.
Who actually uses this? It's equivalent to eval(raw_input( prompt)) but causes a lot of newbie confusion. Python-dev archives revealed that someone tried to get this deprecated but Guido disagreed.
I don't think it should disappear, but it *does* seem more sensible for
"raw_input" to be called "input" (or "readstring " or some such thing) and
"input" to vanish into greater obscurity as "eval_input " or something.
Unfortunately, that would break code if anything relied on "input", so I
guess that would be a Py3K idea, and maybe the whole I/O concept
will be rethought then (if the "print" statement is going to go away,
anyway).
--
Terry Hancock ( hancock at anansispacework s.com )
Anansi Spaceworks http://www.anansispaceworks.com
On 15/07/05, Terry Hancock <ha*****@anansi spaceworks.com> wrote: On Thursday 14 July 2005 07:00 am, Michael Hoffman wrote: Devan L wrote: Use raw_input instead. It returns a string of whatever was typed. Input expects a valid python expression.
Who actually uses this? It's equivalent to eval(raw_input( prompt)) but causes a lot of newbie confusion. Python-dev archives revealed that someone tried to get this deprecated but Guido disagreed. I don't think it should disappear, but it *does* seem more sensible for "raw_input" to be called "input" (or "readstring " or some such thing) and "input" to vanish into greater obscurity as "eval_input " or something. Unfortunately, that would break code if anything relied on "input", so I guess that would be a Py3K idea, and maybe the whole I/O concept will be rethought then (if the "print" statement is going to go away, anyway).
I don't see as "break input() using code" -> "not until py3k" as a
logical cause/effect. No one should be using input() anyway, the only
place it's at-all appropriate is in a python tutorial, with the 'guess
the number' game.
--
Stephen Thorne
Development Engineer
I use input() all the time. I know many people say it ain't safe, but
whose going to use it to crash their own comp? Only an insane person would,
or a criminal trying to cover his/her tracks.
Sorry if I waded into the debate, but this debate originated from one of
my posts.
Nathan Pinno
----- Original Message -----
From: "Stephen Thorne" <st************ @gmail.com>
To: <ha*****@anansi spaceworks.com>
Cc: <py*********@py thon.org>
Sent: Sunday, July 17, 2005 11:12 PM
Subject: Re: Who uses input()? [was Re: question on "input"] On 15/07/05, Terry Hancock <ha*****@anansi spaceworks.com> wrote: On Thursday 14 July 2005 07:00 am, Michael Hoffman wrote: > Devan L wrote: > > Use raw_input instead. It returns a string of whatever was typed.
Input > > expects a valid python expression. > > Who actually uses this? It's equivalent to eval(raw_input( prompt))
but > causes a lot of newbie confusion. Python-dev archives revealed that > someone tried to get this deprecated but Guido disagreed.
I don't think it should disappear, but it *does* seem more sensible for "raw_input" to be called "input" (or "readstring " or some such thing)
and "input" to vanish into greater obscurity as "eval_input " or something.
Unfortunately, that would break code if anything relied on "input", so
I guess that would be a Py3K idea, and maybe the whole I/O concept will be rethought then (if the "print" statement is going to go away, anyway).
I don't see as "break input() using code" -> "not until py3k" as a logical cause/effect. No one should be using input() anyway, the only place it's at-all appropriate is in a python tutorial, with the 'guess the number' game.
-- Stephen Thorne Development Engineer -- http://mail.python.org/mailman/listinfo/python-list
"Nathan Pinno" <fa********@hot mail.com> wrote in message
news:BA******** *************** ***********@phx .gbl... I use input() all the time. I know many people say it ain't safe, but whose going to use it to crash their own comp? Only an insane person would,
This is usage Guido intended it for, not for production apps distributed to
world.
Hi, folks --
I'm a Python newbie. As you can see from the session copied below, I have the latest version of Python and I've been using the Editor-Shell of the latest version of Boa Constructor while going through some Python tutorials. Everything was working as expected until I started using the raw_input built-in function. There seems to be some unreliable behavior in the Boa Editor - Shell. The input that is entered has the first four bytes dropped before it is stored in the test_string. The problem is inconsistant. It sometimes works fine, then starts dropping the first four characters again. The Idle IDE shell does not exhibit this problem. Any ideas, oh Knights of Ni?? Thanks! :)
-- Jerry Kreps
+++++++++++++++ +++++++++++++++ +++++++++++++++ +++++
# Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)]
# wxPython 2.6.1.0, Boa Constructor 0.4.4
# Type "copyright" , "credits" or "license" for more information.
>>> test_string_01 = raw_input("What is your name?")
What is your name?
<<<
Sir Lancelot
>>> print test_string_01
Lancelot
>>> test_string_02 = raw_input("What is your quest? ")
What is your quest?
<<<
To seek the grail
>>> print test_string_02
eek the grail
>>> test_string_03 = raw_input("What is your favorite color?")
What is your favorite color?
<<<
Orange
>>> print test_string_03
ge
>>> test_string_04 = raw_input("Why are the first four characters dropped? ")
Why are the first four characters dropped?
<<<
Run away!!!
>>> print test_string_04
away!!!
>>>
+++++++++++++++ +++++++++++++++ ++++++++++++++
Hi, again.
Since the post before it was over two months ago, I am moving my previous post directly above to a new thread in hope that it will get more notice. I hope this does not break any forum rules.
-- Jerry Kreps :o
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Pete Wilson |
last post by:
Hi folks --
The page at
http://www.pwilson.net/submit-demo.html
will not validate. The validator at http://validator.w3.org tells me I
can't have an input inside a form.
Would some kind soul please tell me what I'm doing wrong?
|
by: John Oliver |
last post by:
I'd like the email produced by FormMail to show a specific From: address
rather than postmaster@server.host.name Googling isn't helping me...
not sure what to look for :-(
--
* John Oliver http://www.john-oliver.net/ *
* California gun owners - protect your rights and join the CRPA today! *
* http://www.crpa.org/ *
* San Diego shooters come to...
|
by: Jonathan |
last post by:
Hi all:
I originally posted this in an HTML forum, but have realized that the
solution may (a) require a server-side change or (b) be non-existent.
In any case, since the page I'm dealing with is a PHP page and the
problem has to do with an auto-inserted "input" element, I'll post it
here, too. I'd appreciate any advice, commentary, or even pessimistic
sympathy if I'm just SOL. - Thanks.
I am pasting some code below that I am having a...
|
by: k386 |
last post by:
I am having trouble creating a hidden form field, or least having it accessible from getElementById.
Rough overview:
I am reading an XML file through XMLhttpRequest and outputting each item into a unique div tag, which has a dynamically generated name, then appending each div tag to an existing div tag. This is working A-OK.
Here's the problem:
Basically so I can show a general section - ie. Bookmarks, Blog Posts, etc - then show or...
|
by: Ulysse |
last post by:
Hello,
I need to clean the string like this :
string =
"""
bonne mentalité mec!:) \n <br>bon pour
info moi je suis un serial posteur arceleur dictateur ^^*
\n <br>mais pour avoir des resultats probant il
faut pas faire les mariolles, comme le "fondateur" de bvs
| |
by: Angus |
last post by:
I am trying to change the selection in Javascript - but this HTML element is
not a standard option control.
On the web page it looks like a dropdown list - and you click on the right
hand down arrow and you see the entries in a dropdown. But how would I
control this thing from javascript?
Here is the HTML:
<div class="selection" style="top:0; left:89; width:159; height:21;"
|
by: Maria Sudderman |
last post by:
I have a prblem with the "onClick" command.
onClick="insert('<a href="URI">', '</a>')">
but this is not correct! why?
Maria
|
by: Apple1 |
last post by:
Hello!
I would like to switch elements on the fly.
Dynamicly turn "A" elenent an "input" tag.
This is what I tried:
<html>
<head>
<script>
|
by: sixtyfootersdude |
last post by:
Good Morning!
I am just starting to learn perl and I am somewhat mistifide about when I should do:
print("@input");
and when I should do:
print(@input)
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |