473,320 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

readline module and white-space

Dear all,

I'm trying to use Python's readline module but I'm having some trouble.
In particular, autocompletion seems to "get stuck" on white spaces.
Please take a look at this code snippet:
import readline

def completer(text, state):

text = text

list = ['a dog', 'artsy']

if len(text) == 0: expressions = list

else: expressions = [expression for expression in list if
expression.startswith(text)

try:
return expressions[state]
except IndexError:
return None

return

# main code:

readline.parse_and_bind("tab: complete")
readline.set_completer(completer)

string = raw_input("type something: ")
print "typed: " + string
If I type "a" at the prompt and then press tab, both options are
displayed. However, if I then type "[space]d" and then once again ask
for auto-completion (I would expect getting "a dog" filled in for me)
nothing happens.

What am I doing wrong? Can I expect auto-completion to correctly handle
this case?

Thanks in advance for any help,

Mack

Jul 19 '05 #1
1 2002
Take a look at readline.get_completer_delims() and
readline.set_completer_delims().

Jul 19 '05 #2

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

Similar topics

2
by: Juan Stang | last post by:
Hope someone can help ... My Python sys.version prints out as follows: '2.3.3 (#51, Dec 18 2003, 20:22:39) ' I'm also running Windows XP SP1 and I have installed PyGame 1.6, wxWindows 2.5 and...
1
by: Jonathan Daugherty | last post by:
Hello all, I've read some posts here talking about the fact that the 'readline' module packaged with python is only good for augmenting the behavior of the interactive interpreter. Can anyone...
3
by: michele.simionato | last post by:
This a case where the documentation is lacking. The standard library documentation (http://www.python.org/dev/doc/devel/lib/module-rlcompleter.html) gives this example try: import readline...
0
by: Brano Zarnovican | last post by:
Hi ! I'd like to init curses and still have working Python interactive command line. I found that you can replace stdin/stdout/stderr like this: #!/usr/bin/python -i import curses import...
1
by: placid | last post by:
Hi all, Just wondering if the cmd module in python uses "busy waiting" for "polling" user command input as this is inefficient. Cheers
4
by: David Bear | last post by:
I built python 2.4.2 for suse linux 9.3. I configured it to be a separate instance of python from the version packaged with suse. Now when I start it I get an error: python Python 2.4.2 (#4,...
0
by: benjamin.grant | last post by:
can configure, make and install everything fine. I'm using python 2.4 I have ubuntu dapper drake. I am trying to install hplip which requires python. When I do this, this also works but while...
2
by: Chris Miles | last post by:
On a standard Solaris 10 installation with Sun-supplied open-source packages installed (like SFWrline for readline libs) I cannot seem to force Python configure/setup.py to build with readline...
1
by: Siddhant | last post by:
Hi! I am having some doubts related to the readline module. I hope someone could clear them. 1. What exactly does the readline.get_line_buffer() function do? Does it return whatever is the...
2
by: Grant Edwards | last post by:
I'm trying to figure out how to use the gnu readline library so that when my program is prompting the user for input there is line editing and history support. I've read and re-read the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.