Input statement question

From: ron (radam2_at_tampabay.rr.com)
Date: 10/24/03


Date: Fri, 24 Oct 2003 20:34:18 GMT


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?



Relevant Pages

  • Re: Is this good use of Properties?
    ... >> nor in the business of programming as a backing of design-heuristic ... >>>Assuming some class external to string needed to know it's length How would you get it? ... >>>I need to send it across the pipe to another process (I don't control the format).. ...
    (microsoft.public.dotnet.languages.csharp)
  • Proposal: String::Format::General
    ... It provides format string parsing and output assembly, you provide the code that implements the individual conversion characters. ... Format syntax is kind of a cross between sprintf and strftime, but how close it is to each of these depends on the semantics implemented by the user. ... Note that the following is pre-alpha documentation; the interface to the output conversion code has changed since yesterday, ... conversion character, and contain a number of optional fields which may ...
    (comp.lang.perl.modules)
  • Re: Regular Expression - old regex module vs. re module
    ... If you want to include backslashes in a string, ... a one character string, which is unlikely to be what you wanted. ... formating characters before a format, then you should use a negative ... #read in and parse a format template ...
    (comp.lang.python)
  • Re: js Newbie
    ... >>born with the talent of programming. ... > Delete all the vowels from a string. ... > Check whether each character is a vowel, and if it is, delete it. ...
    (microsoft.public.scripting.jscript)
  • Re: Check for Common character sequence ( I will pay)?
    ... Dude, programming is all problem-solving. ... You need to identify character sequences of 3 or more characters that appear ... in more than one string. ... and test each 3-character sequence that results. ...
    (microsoft.public.dotnet.framework)