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

2005-07-30 Thread levander
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.

-- 
http://mail.python.org/mailman/listinfo/python-list


Emacs and pdb after upgrading to Ubuntu Feisty

2007-05-05 Thread levander
I've been using pdb under emacs on an Ubuntu box to debug python
programs.  I just upgraded from Ubuntu Edgy to Feisty and this combo
has stopped working.  Python is at 2.5.1 now, and emacs is at 21.41.1.

It used to be I could just "M-x pdb RET pdb  RET" and be
presented with a prompt where I could debug my script, as well as an
arrow in another source code buffer indicating where I am in the
source code.

Now however, when I do "M-x pdb RET pdb ~/grabbers/npr-grabber.py -s
WESUN", I get this is in a buffer called *gud*:

Current directory is /home/levander/grabbers/

No prompt or anything follows it, just that one line.  It doesn't pop
up an arrow in the other buffer either.  None of the regular commands
like 'n', 's', or 'l' do anything here.  So, I did a 'Ctrl-C' and got:

> /home/levander/grabbers/npr-grabber.py(24)()
-> """
(Pdb) > /home/levander/grabbers/npr-grabber.py(30)()
-> import getopt
(Pdb) Traceback (most recent call last):
  File "/usr/bin/pdb", line 1213, in main
pdb._runscript(mainpyfile)
  File "/usr/bin/pdb", line 1138, in _runscript
self.run(statement, globals=globals_, locals=locals_)
  File "bdb.py", line 366, in run
exec cmd in globals, locals
  File "", line 1, in 
  File "/home/levander/grabbers/npr-grabber.py", line 30, in 
import getopt
  File "/home/levander/grabbers/npr-grabber.py", line 30, in 
import getopt
  File "bdb.py", line 48, in trace_dispatch
return self.dispatch_line(frame)
  File "bdb.py", line 66, in dispatch_line
self.user_line(frame)
  File "/usr/bin/pdb", line 144, in user_line
self.interaction(frame, None)
  File "/usr/bin/pdb", line 187, in interaction
self.cmdloop()
  File "cmd.py", line 130, in cmdloop
line = raw_input(self.prompt)
KeyboardInterrupt
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /home/levander/grabbers/cmd.py(151)cmdloop()
-> pass
(Pdb)

It's wierd because at the bottom of that call stack, it does look like
it's wating for input, but no input works...  And, after I hit Ctrl-C
I do get a prompt as you see at the bottom of that listing just
above.  Now I type "quit" and get:

Post mortem debugger finished. The /home/cponder/grabbers/npr-
grabber.py will be restarted

Anybody can tell me who to get pdb working under emacs on Ubuntu
Feisty?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Emacs and pdb after upgrading to Ubuntu Feisty

2007-05-08 Thread levander
Okay, thanks Alexander and Bernstein.  I'll lookinto Emacs 23, but I'm
worried about compatibility with modes.  Does all the stuff that works
in Emacs 21 work in 23?  Like even that ipython.el file, does it work
in Emacs 23?  And, I probably will report a bug to either Ubuntu's
Launchpad or to Debian's package maintainer for pdb mode (which
apparently has been integrated into just the gud mode stuff, at least
that's how it looks from looking around on my system).  Does Debian
have a web site for reporting bugs like Ubuntu does?  Or, do I just
email the package maintainer?

I'm messing around with ipython.el and ipython now.  It looks like if
you just want to step through some code that isn't throwing any
execption, you have to modify the source code of your script to tell
ipython to stop on this line and start debugging here?  With all the
raving about ipython, I'm sure it's a great product.  But, this thing
about having to modify your source code really sounds like it sucks.
I'd be surprised if it were difficult to implement a command line
option for ipython that tells it to open this file and then start
debugging it from the top.  And, have the emacs mode operate much like
it does with pdb, where emacs remembers your command line when you
invoked pdb, so you just hit "M-x pdb RET RET RET ..." to open up your
file.  But, maybe I just haven't foud it yet?


-- 
http://mail.python.org/mailman/listinfo/python-list