473,652 Members | 3,039 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Input statement question

ron


Hi, I'm still new at Python and have been away from programming for a
number of years in general. I apologized in advance if this has been
discussed extensively already.
Is the input() function new? There doesn't seem to be very many
examples of it's use.

After a lot of searching I did find both the input() and raw_input()
statement definitions. I don't understand the reasoning behind making
input() equivalent to "eval (raw_imput[prompt])" the default
behavior, and "raw_input([prompt])" input standard strings?

The fact that there needs to be a warning about the input() function
is indication to me that it may need to be changed.

It seems to me, input() should get a standard string as the default
behavior. And raw input should get strings + control characters
until the specified ending character is received.

variable = input_raw( ['terminate character'] [,'file'] )

The new line character could be the default termination character, the
programmer could change it to something else. And the file argument
would compliment the enhanced print '>>' operations. The input should
always be a string. Eval should be used separately on it if it is
desired. With the above statement you may be able to input multiple
lines and evaluate them as a set. Of course, maybe a syntax_check()
function would be worth while before using the eval() function.

And a regular standard input function would could be...

variable = input( ['prompt'] [,'format'] [,'file'] )

Where prompt is a string, format is a regular expression string
indicating valid input characters, and file is an alternate input
source.

By surrounding the input() with int() or float(), the pre formatted
result can convert it to a numeric format with out errors.

I know there are probably libraries I can import to get these
capabilities. I've just started to explore some of them. This just
seems to be such a basic operations that I think it should be built
in. Maybe it is and I haven't found it yet?
Jul 18 '05 #1
1 4861

"ron" <ra****@tampaba y.rr.com> wrote in message
news:1b******** *************** *********@4ax.c om...


Hi, I'm still new at Python and have been away from programming for a
number of years in general. I apologized in advance if this has been
discussed extensively already.
Is the input() function new? There doesn't seem to be very many
examples of it's use.
No, it's been around for a long time, I suspect from the beginning.
I believe it's on the BDFL's list of features he'd rather not have
made a built-in, but it's not going to go away until Python 3.0.
After a lot of searching I did find both the input() and raw_input()
statement definitions. I don't understand the reasoning behind making
input() equivalent to "eval (raw_imput[prompt])" the default
behavior, and "raw_input([prompt])" input standard strings? The fact that there needs to be a warning about the input() function
is indication to me that it may need to be changed.
There's general agreement that it's a Bad Thing.
It seems to me, input() should get a standard string as the default
behavior. And raw input should get strings + control characters
until the specified ending character is received.

variable = input_raw( ['terminate character'] [,'file'] )

The new line character could be the default termination character, the
programmer could change it to something else. And the file argument
would compliment the enhanced print '>>' operations. The input should
always be a string. Eval should be used separately on it if it is
desired. With the above statement you may be able to input multiple
lines and evaluate them as a set. Of course, maybe a syntax_check()
function would be worth while before using the eval() function.

And a regular standard input function would could be...

variable = input( ['prompt'] [,'format'] [,'file'] )

Where prompt is a string, format is a regular expression string
indicating valid input characters, and file is an alternate input
source.

By surrounding the input() with int() or float(), the pre formatted
result can convert it to a numeric format with out errors.

I know there are probably libraries I can import to get these
capabilities. I've just started to explore some of them. This just
seems to be such a basic operations that I think it should be built
in. Maybe it is and I haven't found it yet?
I don't think you're going to get much traction on this suggestion.
In the last few years, the Python maintainers have gone to wanting
believable use cases for features that aren't blindingly obvious, and
this one isn't in that category.

The history of PEP 289 is a good example of this. It was originally
rejected because of poor syntax and a lack of use cases. It was
recently revived with much better syntax and a small boatload of
use cases, and it looks like it's on the fast path to being included
into 2.4.

So, what's the actual use case? How frequent is it? If you did
a scan of the Python library, how many places would you find
it useful. Hint: it's going to be close to zero. The only reason
I don't say zero is that it might be useful in situations like pyExpect.

John Roth

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2324
by: Florian Wilhelm | last post by:
I have some easy questions, but I cant figure them out: I want to read exactly one char from stdin, there should be no need to hit enter. import sys print "Input: (y/N) ", input = sys.stdin.read(1) print "Your input:", input
6
2468
by: Boyd Reilly | last post by:
I have a form that has the user pick the type of question he will answer. The input field will be a text, numeric or date type. So, after the question is answered, I need to change the input statement. This resembles what I am doing: <form name="frm1"> Step 1 - Choose a File: <select name="selA" OnChange="makeinputbox;" width="200" style="width:200"> <option value="">Date of Birth</option> <option value="MASTER">Age</option>
8
1902
by: b83503104 | last post by:
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):
4
5082
by: wd.jonsson | last post by:
Hello everyone! I have a piece of code that looks like this: if len(BuildList) 0: print "The script found %d game directories:" % len(BuildList) print num = 0 for i in BuildList: print str(num) +" " + i num = num + 1
2
2950
by: joshusdog | last post by:
I'm writing a C++ application with an embedded Python interpreter. Command text is captured and passed to the interpreter a single line at a time. My question is this: is there a simple way of determining whether a given input line of text will cause the prompt to change from the regular ">>>" to the multi-line "..." before sending the text to the interpreter? I suppose the completely correct solution would be tokenize and parse the entire...
2
3916
by: Killer42 | last post by:
The Input #1 statement simply reads in one line from a text file (in this case you INI file) and places the values from it into one or more variables. So what you are reading in this statement is "#Please do not delete this file". My guess is that would all be placed in the first variable, a$. The information held in your file is much more complex than can be handled by a single Input # statement. Probably your best bet is to keep looping and...
10
4364
by: strife | last post by:
Hi, This is a homework question. I will try to keep it minimal so not to have anyone do it for me. I am really just stuck on one small spot. I have to figure out the highest number from a users input. I give them a menu to choose from, and I am stuck on only one of the choices. When this choice is picked I must allow the user to enter how many numbers he/she wants to enter; then I must figure out which number is the highest. I have...
14
12795
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in case it's a question, i want to popup a messageBox or something, and bring back to the batch file the result (Yes\No question). I know how to excute the batch file and get all the Standard output at the end, but i don't know who can i read it line by...
26
3104
by: Bert | last post by:
Hi, I'm unhappy: why doesn't this work? char enc; char temp; for(int i=0;i<10000;i++){ fscanf(in,"%s",&temp); if(temp=='#')break; else
0
8367
marktang
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...
0
8279
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,...
0
8811
Oralloy
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...
0
8703
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8467
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,...
0
5619
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();...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2703
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.