473,406 Members | 2,956 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,406 software developers and data experts.

auto-completion history

Hi Folks,

I have auto-completion set up in my python interpreter so that if I
hit the tab key it will complete a variable or a python command*. eg.
if I type
imp and if I then hit the tab key, the interpreter will complete it to... import
Now, I also use Matlab at the command line a lot and it has a nice
additional auto-completion feature, whereby, if you type a few letters
and hit the up-arrow, it will go back to the last command you typed
that began with those letters. If you keep hitting up-arrow it will
cycle through all the commands you typed beginning with these letters.
eg. if I type...
import datetime
import sys
today = datetime.date.today()
imp
After typing the last imp I hit up-arrow once I would like the history
to return to import sys and if I hit twice, I would like to go to import datetime


Does a feature like this already exist in python???

Thanks

The PorterBoy - "Lovely day for a Guinness"

ps...
* If you are unsure how to set up auto completion (UNIX only) ...

1. Include this line in your .tcshrc file (or equivalent in .bashrc):
setenv PYTHONSTARTUP "$HOME/.pythonrc.py"
2. In the file ~/.pythonrc.py include the lines:
import rlcompleter, readline
readline.parse_and_bind('tab: complete')
del rlcompleter, readline
3. For the effect to work, open a new terminal, and type python. If
you do not fire up a new session, python has no way to become aware of
your changes.
Jul 18 '05 #1
1 2220
porterboy wrote:
Hi Folks,

I have auto-completion set up in my python interpreter so that if I
hit the tab key it will complete a variable or a python command*. eg.
if I type
imp and if I then hit the tab key, the interpreter will complete it to... import


Now, I also use Matlab at the command line a lot and it has a nice
additional auto-completion feature, whereby, if you type a few
letters and hit the up-arrow, it will go back to the last command
you typed > that began with those letters. If you keep hitting
up-arrow it will cycle through all the commands you typed beginning
with these letters. eg. if I type...

Does a feature like this already exist in python???


It's not in python, it's in readline library. To read the documentation
do 'man readline'

readline.parse_and_bind('"\e[A": history-search-backward')

works for me. To find out what your up arrow key sends remove
\e[A and hit on your keyboard Control-v and then up arrow.

Serge.

Jul 18 '05 #2

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

Similar topics

2
by: Manlio Perillo | last post by:
Hi. This post follows "does python have useless destructors". I'm not an expert, so I hope what I will write is meaningfull and clear. Actually in Python there is no possibility to write code...
1
by: Glabbeek | last post by:
I'm changing the layout of my site. Instead of using tables, I will use DIVs. It's working fine, except for 1 thing: In IE6 some DIVs are not the correct width. Mozilla and Opera are showing the...
5
by: Robert Downes | last post by:
I'm using the following in a page that I'm testing in Mozilla: p.actionLinkBlock {border: 1px #000000 dashed; padding: 0.2cm; width: auto} But the dashed border is extending to the right-edge...
20
by: Vijay Kumar R. Zanvar | last post by:
Hello, Unlike register, auto keyword can not be used to declare formal parameter(s). Is there any specific reason for this? Kind regards, Vijay Kumar R. Zanvar
6
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I...
5
by: Samuel | last post by:
Hi, I am running into a problem of mixing UICulture = auto and allowing users to select culture using a dropdown list. I am detecting a querystring, "setlang", and when found, setting the...
5
by: maya | last post by:
at work they decided to center divs thus: body {text-align:center} #content {width: 612px; text-align:left; margin: 0 auto 0 auto; } this works fine in IE & FF, EXCEPT in FF it doesn't work if...
22
by: nospam_news | last post by:
I currently get asked about my usage of "auto". What is it for? The keyword is clearly superflous here. In contrast to the huge majority of C/C++ developers I write definitions very explicitly...
2
by: Piotr K | last post by:
Hi, I've encountered a strange problem with Firefox which I don't have any idea how to resolve. To the point: I've <divelement with a style "height: auto" and I want to retrieve this value...
21
by: JOYCE | last post by:
Look the subject,that's my problem! I hope someone can help me, thanks
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...
0
isladogs
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...

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.