Providing 'default' value with raw_input()?
Roger Upole
rupole at hotmail.com
Fri Dec 23 00:05:05 EST 2005
If you have Pywin32 build 205 installed, you can use the
win32console module to add the data to the typeahead
buffer before you call raw_input.
import win32console
stdin=win32console.GetStdHandle(win32console.STD_INPUT_HANDLE)
def raw_input_with_default(prompt, default_val):
keypresses=[]
for c in default_val:
evt=win32console.PyINPUT_RECORDType(win32console.KEY_EVENT)
evt.Char=unicode(c)
evt.RepeatCount=1
evt.KeyDown=True
keypresses.append(evt)
stdin.WriteConsoleInput(keypresses)
return raw_input(prompt)
data=raw_input_with_default('modify this: ','some data')
print data
hth
Roger
"planetthoughtful" <planetthoughtful at gmail.com> wrote:
> Hi Steve,
>
> As keir mentioned, my goal is to be able to edit the value returned
> from a record stored in SQLite, so that it can be updated with the new
> value.
>
> To give a little background: as a learning exercise I'm writing a
> command line app that will allow me to quickly capture todo items
> (based on a similar concept used by an app for the Mac described on
> 43folders.com). I have the functionality working for adding todo items,
> and listing items by various criteria, and updating the status of
> items, but haven't included any functionality for being able to edit
> items.
>
> It seems, according to kier, that this simply can't be done via the
> command line in DOS, which is a shame.
>
> Sorry I didn't explain myself very well in my original post.
>
> Much warmth,
>
> planetthoughtful
>
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
More information about the Python-list
mailing list