- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Completion function for GNU readline
Unix readline module has tab completion mechanism. To get these features, we have to use rlcompleter module. It can be used in python’s interactive mode.
To use this module, we should import it using −
There is a class called Completer class −
Method Completer.complete(text, state)
This method is used to return the tab completion output. If there is a ‘.’ in the text, then it will try to get all related members of that command. When there is no dot ‘.’ it will just complete the text.
import rlcompleter import sys my_completer = rlcompleter.Completer() phrase_list = ['co', 'sys.m', 'cal'] for phrase in phrase_list: print(phrase + ' (TAB): ', end='') try: for i in range(50): terms = my_completer.complete(phrase, i) if terms is None: break print(terms, end='\t') except: pass print()
$ python3 example.py co (TAB): continue compile( complex( copyright( sys.m (TAB): sys.maxsize sys.maxunicode sys.meta_path sys.modules cal (TAB): callable(
- Python GNU readline Interface
- Give examples for the percentage of completion method
- Write the journal entries for the percentage of completion method
- Ordered Set and GNU C++ PBDS
- What are the differences between readline() and readlines() in Selenium with python?
- What is the percentage of the completion method?
- What is the difference between Read() and ReadLine() methods in C#?
- How to display completion progress of a task in HTML5?
- What are the differences between -std = c++11 and -std = gnu++11?
- What is the difference between Read(), ReadKey() and ReadLine() methods in C#?
- Python program for permutation of a given string inbuilt function in python
- How to create a combo box with auto-completion in Tkinter?
- How can I import modules for a Python Azure Function?
- Python program for the permutation of a given string inbuilt function in python
- What is the use of ON COMPLETION PRESERVE clause while creating the event?