473,701 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Asking the user a question and giving him a default answer he can edit

I'm trying to figure out the python readline module to see if it will
do this.

Basically, I've got a bunch of questions to ask a user, the vast
majority of which, the answer will only vary by the last few
characters. What I'd like to do is every time the user is asked a
question, give him the default answer as just whatever he answered last
time. But, I want him to be able to edit this default answer. And, the
editted answer is what I want to operate on inside my program.

raw_input() lets the user edit the prompt I send. But, internally, it
must ignore the backspace key or something. Because, it only returns
new letters that the user has typed in. Not anything that he has
backspaced over or deleted.

You can edit whatever you put out there with raw_input, but it's like
internally that function ignores the backspace key, and just returns
whatever new characters the user types.

Basically, I want to the user a line editor, with a default value
already populated.

Anybody know how to do something like this?

I've been playing around with doing it in bash, figuring I can use
popen to spawn the process if I can figure it out, but haven't figured
it out yet.

Jul 31 '05 #1
1 1346
"levander" <le******@minds pring.com> writes:
Basically, I've got a bunch of questions to ask a user, the vast
majority of which, the answer will only vary by the last few
characters. What I'd like to do is every time the user is asked a
question, give him the default answer as just whatever he answered last
time. But, I want him to be able to edit this default answer. And, the
editted answer is what I want to operate on inside my program.
Something like this?

/>> def f():
|.. readline.set_st artup_hook(lamb da :readline.inser t_text('aaa'))
|.. return raw_input()
Basically, I want to the user a line editor, with a default value
already populated.

Or you could use my pyrepl package (see google for that).


In case you're not a computer person, I should probably point out
that "Real Soon Now" is a technical term meaning "sometime before
the heat-death of the universe, maybe".
-- Scott Fahlman <se*@cs.cmu.edu >
Jul 31 '05 #2

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

Similar topics

by: Deniz Bahar | last post by:
Hi, My english is not top notch and I am trying to understand what K&R2 Ex 5-11 is asking for (pg 118). It says: Modify the programs entab and detab (which I completed from chapter 1 and have on hand) to accept a list of tab stops as arguments. Use the default tab settings if there are no arguments. I am having difficulty understanding the question (not asking for answer to it). Any help would be helpful (thus the common root "help").
by: J. Miller | last post by:
I have a datagrid with update/cancel on one side, a button on the other which, when clicked, will take the user to a page that allows them to e-mail that particular observation's data. My problem, is that I have some columns that are sortable. To make everything work, I can wrap the e-mail code in a 'if not.postback' statement (wrong I know--testing here), but then, my sorts/updates/cancels don't work because an error is thrown from the...
by: Damon | last post by:
I am working on a site in which I would like to have two dropdowns that will allow a user to navigate through the administrative pages of the site. The first would allow the user to choose the particular site that they would like to edit. The second would allow the user to select which admin screen they would like to edit. The second dropdown needs to be populated based on the selection in the first one. I want to encapsulate these...
by: Andy | last post by:
.... as I know the answer will be so simple, but here goes... I cannot creating a new asp.net projects in VS2003 in a directory other than the default suggested directory (i.e. http://localhost/WebApplication1 - and renaming webapplication1). I wanted to follow the guideline in Francesco Balena et.als. latest book, by NOT creating them in this default location so that ALL of the files are kept together, and have therefore wanted to...
by: Demetri | last post by:
I'm trying to determine if we want to use panels or user controls for our pages. Our primary concern is performance, page loading and posting speed. To illustrate my question, lets use the Customer Orders scenario: Problem: User needs to view orders and and edit, add, save on one page called Orders.aspx. To begin with the page contains a grid with basic information about an order. The user can click a row to edit or click an "Add"...
by: Anand | last post by:
Hi, I got the below error while trying create a user from the web site administration tool provided by Asp.NET. I'm using Active directory as a membership store. I could able to add and remove users earlier from this, after this I want to implement the password reset option and to that i've added couple of (5 attributes) to the active directory (Hint Question, Hint Answer, BadPasswordCount, BadPasswordTime, BadPasswordLockOutTime - the...
by: John J. Hughes II | last post by:
I have a DataGridView displaying data from a DataSet. To the right of that I have a custom user control which displays one of the data set fields. The custom user control is bound to the data set object and displays the data correctly when I move from row to row. The problem I am having is the data set always reads the data back and considers it change even when it's not. I am looking for how to change the following code so the...
by: Etienne Hilson | last post by:
Hello the list :-) I do a little program that permit the user to manage list of sentences. This program runs into a linux shell. The user can add, modify and delete the sentences. What I want to do is : When the user want to modify one sentence, I would like to do this :
by: IReallyNeedHelp | last post by:
I have saved the questions using AddQuestion.aspx page i have created but i don't know how to display it and calculate their score. this is the formview i have done, but there is some error <asp:FormView ID="FormView1" runat="server" DataKeyNames="QuestionID" DataSourceID="SqlDataSource1" Width="151px" AllowPaging="True"> <EditItemTemplate> QuestionID: ...
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: 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...
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: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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: 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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.