给Python IDLE加上自动补全和历史功能

redswallow posted @ Sun, 23 May 2010 22:03:41 +0800 in python , 8047 readers

许多时候,我们使用Python,并不用写一个程序,一些不复杂的任务,我更喜欢在 IDLE(也就是交互式提示模式)下输入几行代码完成。然而,在这个模式下编辑代码,也有不够便利的地方,最主要的就是,不能用Tab自动补全,不能记忆 上一次输入的命令(没办法,谁让我们在Shell下习惯了呢)。
这时候,我们可以直接使用Python启动脚本,解决这个问题。

启动脚本的程序非常简单,这里不多说明,只给出代码:

import readline
import rlcompleter
import atexit
import os
# tab autocomplete
readline.parse_and_bind(‘tab: complete’)
# history file
histfile = os.path.join(os.environ['HOME'], ‘.pythonhistory’)
try:
readline.read_history_file(histfile)
except IOError:
pass
atexit.register(readline.write_history_file, histfile)
del os, histfile, readline, rlcompleter

 完成之后,我们把它保存为.pythonstartup,存放在自己的目录下(譬如/home/yurii),再将PYTHONSTARTUP变量指向刚才放的地址,就可以了。最省事的办法是在bashrc中添加这样一行: 

export PYTHONSTARTUP=/home/yurii/.pythonstartup

 这样,不但增加了tab的自动补全功能,而且重新启动IDLE时,通过上下键,还能翻到上次输入的命令,非常方便。

 

Avatar_small
ningyu said:
Mon, 17 Jun 2013 11:06:10 +0800

lz试试alt+p,alt+n,http://forum.ubuntu.org.cn/viewtopic.php?t=249852

Avatar_small
Landon Jackson said:
Fri, 25 Jan 2019 19:18:31 +0800

Appreciate it intended for giving new messages the matter, When i count on understand far more. Tax Advice

Avatar_small
Gay Tube said:
Thu, 16 Apr 2020 22:33:44 +0800

Very nice blog and articles. I am realy very happy to visit your blog. Now I am found which I actually want. I check your blog everyday and try to learn something from your blog. Thank you and waiting for your new post.

Avatar_small
123mvoies said:
Thu, 28 May 2020 16:54:38 +0800

movie drama site online https://123movies7.com

Avatar_small
free sexting website said:
Mon, 15 Jun 2020 01:31:18 +0800

I wish more writers of this sort of substance would take the time you did to explore and compose so well. I am exceptionally awed with your vision and knowledge.

Avatar_small
artes para mídias so said:
Sat, 27 Jun 2020 06:54:12 +0800

Hi there, I found your blog via Google while searching for such kinda informative post and your post looks very interesting for me

Avatar_small
kings lynn nightclub said:
Sat, 04 Jul 2020 04:29:48 +0800

Well everything has some pros and cons but its upto us that how we handle kings lynn nightclubs challenges because its always how do we respond to things.

Avatar_small
bigcommerce data ent said:
Wed, 08 Jul 2020 04:06:58 +0800

I really thank you for the valuable info on this great subject and look forward to more great posts

Avatar_small
Safir Painting said:
Sat, 08 Aug 2020 16:03:15 +0800

It was a very good post indeed. I thoroughly enjoyed reading it in my lunch time. Will surely come and visit this blog more often. Thanks for sharing.

Avatar_small
oferty pracy said:
Fri, 21 Aug 2020 01:28:08 +0800

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well..

Avatar_small
job posting said:
Sat, 22 Aug 2020 21:07:49 +0800

I’m excited to uncover this page. I need to to thank you for ones time for this particularly fantastic read!! I definitely really liked every part of it and i also have you saved to fav to look at new information in your site.

Avatar_small
Immobilien Franchise said:
Thu, 27 Aug 2020 02:17:44 +0800

Only a few blogger would discuss this topic the way you do.’.”`:

Avatar_small
Dj animation de mari said:
Sun, 13 Sep 2020 18:58:41 +0800

Im using a tiny problem I cant subscribe your feed, Im using google reader fyi.

Avatar_small
hansestadt bremen im said:
Wed, 30 Sep 2020 19:54:42 +0800

I am not afraid to find this but this is just insane.

Avatar_small
pak24tv said:
Mon, 05 Oct 2020 20:27:33 +0800

I am happy to find your distinguished way of writing the post. Now you make it easy for me to understand and implement the concept. Thank you for the post. top 10 richest countries in the world top 10 poorest countries in the world top 10 most beautiful places in the world

Avatar_small
QHS Development said:
Tue, 06 Oct 2020 00:18:37 +0800

you have a great weblog here! do you need to have invite posts in my blog?

Avatar_small
RajaQQ said:
Thu, 22 Oct 2020 17:58:11 +0800

As a seller of legal steroids, you can buy Crazy Bulk products, explore stacks and finally get the body you’ve always wanted

Avatar_small
escort said:
Wed, 28 Oct 2020 01:38:18 +0800

This is also a very good post which I really enjoyed reading. It is not every day that I have the possibility to see something like this..

Avatar_small
chiangmai termite said:
Fri, 30 Oct 2020 22:04:58 +0800

กำจัดปลวกเชียงใหม่ ( chiangmai termite ) เป็นบริษัทกำจัดปลวกเชียงใหม่ ฉีดปลวกเชียงใหม่ราคาถูก เน้นความคุ้มค่า เพื่อลดค่าใช้จ่ายของลูกค้า. มีขั้นตอนการฉีดปลวกเหมือนกับบริษัทใหญ่ราคาแพง.เรารับงานทุกตำบล ทุกอำเภอ ในเชียงใหม่ , อำเภอเมืองเชียงใหม่ , ศรีภูมิ , พระสิงห์ , หายยา , ช้างม่อย , ช้างคลาน , วัดเกต , ช้างเผือก , สุเทพ , แม่เหียะ , ป่าแดด , หนองหอย , ท่าศาลา , หนองป่าครั่ง , ฟ้าฮ่าม , ป่าตัน , สันผีเสื้อ , อำเภอจอมทอง , อำเภอเชียงดาว , อำเภอดอยสะเก็ด , อำเภอแม่ริม , อำเภอสะเมิง , อำเภอฝาง , อำเภอแม่อาย , อำเภอพร้าว , อำเภอสันป่าตอง , อำเภอสันกำแพง , อำเภอสันทราย , สันทรายหลวง , สันทรายน้อย , สันพระเนตร , สันนาเม็ง , สันป่าเปา , หนองแหย่ง , หนองจ๊อม , หนองหาร , แม่แฝก , แม่แฝกใหม่ , เมืองเล็น , ป่าไผ่ , อำเภอหางดง , หางดง , หนองแก๋ว , หารแก้ว , หนองตอง , ขุนคง , สบแม่ข่า , บ้านแหวน , สันผักหวาน , หนองควาย , บ้านปง , น้ำแพร่ , อำเภอฮอด , อำเภอดอยเต่า , อำเภออมก๋อย , อำเภอเวียงแหง , อำเภอไชยปราการ , อำเภอแม่วาง , อำเภอแม่ออน , อำเภอดอยหล่อ , อำเภอกัลยาณิวัฒนา ,

Avatar_small
Escort San Diego said:
Sun, 08 Nov 2020 06:33:40 +0800

I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work.

Avatar_small
ROXEN said:
Wed, 11 Nov 2020 02:07:37 +0800

It’s really a fantastic website, thanks for sharing. There's no doubt i would fully rate it after i read what the idea about this article is. You did a nice صيانة غسالات

Avatar_small
check benefits said:
Fri, 13 Nov 2020 04:59:17 +0800

Cool stuff you have and you keep overhaul every one of us

Avatar_small
Glock 17 for sale said:
Tue, 24 Nov 2020 19:00:14 +0800

You have done a amazing job with you website

Avatar_small
bible verses said:
Sat, 28 Nov 2020 19:25:37 +0800

Great survey. I'm sure you're getting a great response.

Avatar_small
bible verses said:
Sat, 28 Nov 2020 20:18:59 +0800

I have recently started a blog, the info you provide on this site has helped me greatly. Thanks for all of your time & work

Avatar_small
polskie kasyno onlin said:
Sat, 05 Dec 2020 22:44:09 +0800

This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the leisure here! Keep up the good work. I have been meaning to write something like this on my website and you have given me an idea.

Avatar_small
android video editor said:
Sat, 12 Dec 2020 19:41:38 +0800

I wish more writers of this sort of substance would take the time you did to explore and compose so well. I am exceptionally awed with your vision and knowledge.

Avatar_small
สล็อต xo said:
Thu, 17 Dec 2020 22:01:08 +0800 Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. สล็อต xo
Avatar_small
Robinjack said:
Mon, 21 Dec 2020 18:32:00 +0800

nice blog and really nice post. i like it. make a fanpage on facebook. mobile form development

Avatar_small
no excuses runner said:
Mon, 04 Jan 2021 14:37:32 +0800

This blog was extremely helpful. I really appreciate your kindness in sharing this with me and everyone else! Betfair vedonlyöntibonus

Avatar_small
Resistance bands said:
Tue, 05 Jan 2021 21:38:09 +0800

Hi there, I found your blog via Google while searching for such kinda informative post and your post looks very interesting for me. Resistance bands

Avatar_small
Best Portable Blueto said:
Wed, 06 Jan 2021 14:20:41 +0800

Incredible articles and awesome design. Your blog entry merits the greater part of the positive input it"s been getting. Best Portable Bluetooth Speaker

Avatar_small
Lsd said:
Wed, 06 Jan 2021 19:05:37 +0800

First You got a great blog .I will be interested in more similar topics. i see you got really very useful topics, i will be always checking your blog thanks. Lsd

Avatar_small
Hemstädning i Malmö said:
Fri, 08 Jan 2021 01:46:31 +0800

One present why galore businesses opt for postcards is because they are overmuch cheaper to be prefab and this can forbear a lot of expenses on the lengthened run.  Hemstädning i Malmö

Avatar_small
kasyno online blik said:
Thu, 14 Jan 2021 22:21:26 +0800

First You got a great blog .I will be interested in more similar topics. i see you got really very useful topics, i will be always checking your blog thanks.

Avatar_small
kasyno online said:
Sun, 17 Jan 2021 01:33:31 +0800

I have bookmarked your website because this site contains valuable information in it. I am really happy with articles quality and presentation. Thanks a lot for keeping great stuff. I am very much thankful for this site.

Avatar_small
polskie kasyno onlin said:
Sun, 17 Jan 2021 22:59:35 +0800

The blog and data is excellent and informative as well

Avatar_small
ryse residences cond said:
Sat, 23 Jan 2021 21:06:22 +0800

At We Walk Together L LC, we are dedicated to providing patients with the best possible care. We at WE WALK TOGETHER LLC are focused on helping you. <a href="https://www.wewalktogetherllc.com/">Telehealth</a>

Avatar_small
free business listin said:
Sun, 31 Jan 2021 07:34:42 +0800

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well..

Avatar_small
Robinjack said:
Wed, 17 Feb 2021 19:42:43 +0800

I precisely had to thank you very much all over again. I’m not certain what I could possibly have undertaken without the entire tactics discussed by you about this situation. Entirely was a very difficult problem for me, however , seeing a specialized strategy you handled that took me to cry for joy. Now i’m grateful for the service and as well , wish you realize what an amazing job you happen to be carrying out instructing the rest with the aid of your blog. I’m certain you haven’t got to know all of us. fever monitoring solution

Avatar_small
schlüsseldienst nord said:
Sat, 20 Feb 2021 06:59:45 +0800

I will really appreciate the writer's choice for choosing this excellent article appropriate to my matter.Here is deep description about the article matter which helped me more.

Avatar_small
Ramadan calendar 202 said:
Sat, 20 Feb 2021 19:34:43 +0800

I recently came across your article and have been reading along. I want to express my admiration of your writing skill and ability to make readers read from the beginning to the end. I would like to read newer posts and to share my thoughts with you.

Avatar_small
Getting rid of Rats said:
Wed, 10 Mar 2021 19:52:29 +0800

i love bloghoping and i really love to comment on your blog.

Avatar_small
sk said:
Thu, 11 Mar 2021 15:08:19 +0800

Yes i am totally agreed with this article and i just want say that this article is very nice and very informative article.I will make sure to be reading your blog more. You made a good point but I can't help but wonder, what about the other side? !!!!!!Thanks เมล็ดกาแฟคั่ว

Avatar_small
background music rem said:
Sun, 21 Mar 2021 01:17:02 +0800

This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck

Avatar_small
no excuses runner said:
Wed, 24 Mar 2021 14:13:12 +0800

YouTube promotion services l Sometimes you just need that extra boost, and that’s where the YouTube promotion services come into play

Avatar_small
SBI HRMS said:
Wed, 07 Apr 2021 14:17:13 +0800

Mails are an important source of communication between many organizations and persons in the new technology, thus eMails are termed an easy way of communication to interact with anyone or send them their greetings. Sometimes the same eMails get trouble, how to block email on icloud mail as you don’t wish to receive the mails from a person or company. Also, some emails can be sent by multiple people with the same content, but you might need them to be blocked. It is easy to block such emails with the help of rules that can be created in the Mailbox, In Gmail, Yahoo, and other mailing platforms, then things might be easier but doing the same in iCloud requires some series of steps.

Avatar_small
you might choose to said:
Fri, 09 Apr 2021 05:30:01 +0800

I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon…

Avatar_small
mieszkanie sprzedaz said:
Sun, 11 Apr 2021 18:45:43 +0800

Through this post, I know that your good knowledge in playing with all the pieces was very helpful. I notify that this is the first place where I find issues I've been searching for. You have a clever yet attractive way of writing.

Avatar_small
mieszkanie sprzedaz said:
Sun, 11 Apr 2021 20:37:51 +0800

This is my first time i visit here. I found so many entertaining stuff in your blog, especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the leisure here! Keep up the good work. I have been meaning to write something like this on my website and you have given me an idea.

Avatar_small
GoalooUS said:
Sat, 24 Apr 2021 10:51:14 +0800

GoalooUS provide you with global sports events information, fast and accurate real-time scores, detailed information of sport matches, team information, player information; Real-time index data, professional data analysis and match outcome prediction recommendations from world-renowned sportsbook companies. GoalooUS

Avatar_small
ball valve said:
Fri, 07 May 2021 00:34:19 +0800

This is a fabulous post I seen because of offer it. It is really what I expected to see trust in future you will continue in sharing such a mind boggling post

Avatar_small
안전공원 said:
Mon, 10 May 2021 02:23:53 +0800

I think this is a standout amongst the most critical data for me. What"s more, i"m happy perusing your article. Be that as it may, ought to comment on some broad things

Avatar_small
dark web sites said:
Mon, 17 May 2021 21:04:48 +0800

I have read your blog it is very helpful for me. I want to say thanks to you. I have bookmark your site for future updates.

Avatar_small
Robinjack said:
Wed, 26 May 2021 00:07:15 +0800

This is the first time I checked out your blog, and honestly, compared to your other posts, Self-Publishing: The New Way or the Short-Cut? | Chronicles of A Broken Spirit is much more well-written! Keep up the good work. Regards, Ricardo Kosloski eprescription software

Avatar_small
asdzxc said:
Thu, 27 May 2021 01:41:36 +0800 pleasant post, stay aware of this fascinating work. It truly regards realize that this subject is being secured likewise on this site so cheers for setting aside time to talk about this! Personal Trainer San Diego
Avatar_small
asdzxc said:
Thu, 27 May 2021 03:35:37 +0800

gabung sekarang juga taruhan situs judi slot dan casino online terpercaya di indonesia casino online

Avatar_small
Canadian zip codes said:
Thu, 27 May 2021 22:54:18 +0800

I have express a few of the articles on your website now, and I really like your style of blogging. I added it to my favorite’s blog site list and will be checking back soon…

Avatar_small
asdzxc said:
Tue, 01 Jun 2021 23:08:17 +0800

CBD stands for cannabidiol. It is the second most prevalent of the active ingredients of cannabis (marijuana). While CBD is an essential component of medical marijuana, it is derived directly from the hemp plant, which is a cousin of the marijuana plant. While CBD is a component of marijuana (one of hundreds), by itself it does not cause a “high.” calming cbd products

Avatar_small
no excuses runner said:
Wed, 02 Jun 2021 15:21:48 +0800

We will do our best to provide you with safe and enjoyable mobile hold'em by introducing the online hold'em site and introducing Texas hold'em and recommending various new member benefits and free coupon events. 홀덤사이트

Avatar_small
Pasir Ris 8 showflat said:
Fri, 04 Jun 2021 01:26:51 +0800

Pasir Ris 8 is located in District 18 of the Pasir Ris precinct. The new Pasir Ris Central integrated development is proudly developed by Allgreen Properties. Pasir Ris 8 showflat

Avatar_small
ez monster deals die said:
Sat, 05 Jun 2021 02:35:54 +0800

I surely acquiring more difficulties from each surprisingly more little bit of it

Avatar_small
bandarqq said:
Mon, 07 Jun 2021 00:35:14 +0800

You actually make it look so easy with your performance but I find this matter to be actually something which I think I would never comprehend. It seems too complicated and extremely broad for me. I'm looking forward for your next post, I’ll try to get the hang of it!

Avatar_small
dewascore said:
Mon, 07 Jun 2021 20:01:49 +0800

I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post.

Avatar_small
yockjack said:
Mon, 14 Jun 2021 19:12:12 +0800

交友app推薦 https://datingapp.com.hk/

Avatar_small
no excuses runner said:
Mon, 14 Jun 2021 19:14:24 +0800

There are only a handful of them and extremely limited potential sites that they can be built on. To top it off, the Pasir Ris 8 is a integrated development and ... Pasir Ris 8

Avatar_small
Faddy said:
Mon, 14 Jun 2021 21:40:09 +0800

The lemon law attorneys of the Los Angeles based California Lemon Law Center provide services for owners and lessees of new and used cars. Lemon Law Glendale

Avatar_small
appliance repair nea said:
Mon, 14 Jun 2021 23:35:26 +0800

Man's lives, such as uncontrolled huge amounts, definitely not while countries furthermore reefs, challenging to seismic disturbance upward perfect apply. appliance repair near me

Avatar_small
disability discrimin said:
Mon, 21 Jun 2021 03:00:20 +0800

AQUINO LAW has over 24 years of experience providing clients with excellent customer service, complete information, honesty, prompt answers to questions and all options explained. disability discrimination attorney

Avatar_small
Faddy said:
Tue, 22 Jun 2021 18:34:21 +0800

This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. 토토사이트

Avatar_small
asdzxc said:
Thu, 24 Jun 2021 01:38:20 +0800 Online Shopping Store, We sell high quality products shipped from the US, Spain. Fashion, Electronics, Home & Garden, Beauty, sporting goods & more. Online shopping in us

Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter