Tip 31 Remember, input() Remembers

Pythonic Programming — by Dmitry Zinoviev (40 / 116)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Pick to str() or to repr() | TOC | Do Linear Algebra in Python 👉

★3.4+ On UNIX-like systems, such as Linux, macOS, and UNIX itself, function input (Tip 9, Let input() Speak for Itself) uses the POSIX readline interface. The interface offers extended capabilities:

  • Editing: moving the cursor backward and forward; deleting, inserting, and replacing characters; copying and pasting strings
  • Configuration: modifying key bindings, adding pre-recorded macros, and even defining variables — all via the ~/.inputrc file
  • History: scrolling for the previously entered strings with the Up and Down keys; searching through the history (with Ctrl+r)

A detailed explanation of the readline functionality is outside the scope of the book. You can read more about it in the manual (man readline).

Bear in mind that the readline used by input and the readline used by the Python console command line is the same readline. Anything you typed on the console will show up in the input history and the other way around.

👈 Pick to str() or to repr() | TOC | Do Linear Algebra in Python 👉

Pythonic Programming by Dmitry Zinoviev can be purchased in other book formats directly from the Pragmatic Programmers. If you notice a code error or formatting mistake, please let us know here so that we can fix it.

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.