0

I have a terminal emulator on my phone (termux to be exact) and i made a python script that formats my contacts into a list of tuples, where the first tuple element is the contact name, and the second is the phone number. I want to print the phone number of a contact by typing in the name. This is easy to do, but then i realised that you need to know and type the entire contact name, which can be long. Terminals have this nice feature: tab completion, and i am curious if i can use it a bit differently than intended.

Can i make it that, after the list has ben built, i can ask the user to type in the contact name, and then when he starts typing the name and presses TAB for the script to auto-complete or list out possible names (like in bash for programs)?

someoneb100
  • 141
  • 1
  • 13
  • If you specifically want to use TAB, that probably relies on the interpreter; for expample, `ipython` version > 3 supports this, but I don't think the standard `python` interpreter does. However, if you just want to save typing time, you could probably write a function that iterates over the dictionary looking for partial key matches, so you wouldn't need to type in the full name each time. – 0x5453 May 31 '17 at 13:21
  • Why a list of tuples instead of a dictionary? In any event, I've never heard of a tab-completion feature that would autocomplete based on strings in a tuple... – juanpa.arrivillaga May 31 '17 at 13:49

0 Answers0