Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 182209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:53:58+00:00 2026-05-11T14:53:58+00:00

Several months ago, I wrote a blog post detailing how to achieve tab-completion in

  • 0

Several months ago, I wrote a blog post detailing how to achieve tab-completion in the standard Python interactive interpreter–a feature I once thought only available in IPython. I’ve found it tremendously handy given that I sometimes have to switch to the standard interpreter due to IPython unicode issues.

Recently I’ve done some work in OS X. To my discontent, the script doesn’t seem to work for OS X’s Terminal application. I’m hoping some of you with experience in OS X might be able to help me trouble-shoot it so it can work in Terminal, as well.

I am reproducing the code below

import atexit import os.path  try:     import readline except ImportError:     pass else:     import rlcompleter      class IrlCompleter(rlcompleter.Completer):         '''         This class enables a 'tab' insertion if there's no text for         completion.          The default 'tab' is four spaces. You can initialize with '\t' as         the tab if you wish to use a genuine tab.          '''          def __init__(self, tab='    '):             self.tab = tab             rlcompleter.Completer.__init__(self)           def complete(self, text, state):             if text == '':                 readline.insert_text(self.tab)                 return None             else:                 return rlcompleter.Completer.complete(self,text,state)       #you could change this line to bind another key instead tab.     readline.parse_and_bind('tab: complete')     readline.set_completer(IrlCompleter('\t').complete)   # Restore our command-line history, and save it when Python exits. history_path = os.path.expanduser('~/.pyhistory') if os.path.isfile(history_path):     readline.read_history_file(history_path) atexit.register(lambda x=history_path: readline.write_history_file(x)) 

Note that I have slightly edited it from the version on my blog post so that the IrlCompleter is initialized with a true tab, which seems to be what is output by the Tab key in Terminal.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T14:53:59+00:00Added an answer on May 11, 2026 at 2:53 pm

    To avoid having to use more GPL code, Apple doesn’t include a real readline. Instead it uses the BSD-licensed libedit, which is only mostly-readline-compatible. Build your own Python (or use Fink or MacPorts) if you want completion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a small PHP application several months ago that uses the WordPress XMLRPC
Several months ago I learned from an answer on Stack Overflow how to perform
I managed to run cvs2git several months ago and created a git repository for
Several months (maybe even a year or two) ago, I saw an asp .net
I've started to use XCode several months ago, after using IntelliJ for several years,
My university has several programs available for download. About 6 months ago I downloaded
Several months ago I stumbled across something regarding large string buffers where the buffers
I downloaded and installed Eclipse using Yoxos a few months ago. Since then, several
Several months ago, I followed http://aws.amazon.com/articles/1663 and got it all running. Then, my PC
Several months ago, Microsoft decided to change up the HttpResponseMessage class. Before, you could

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.