14. Διαδραστική Επεξεργασία Input και Αντικατάσταση Ιστορικού

Ορισμένες εκδόσεις του interpreter της Python υποστηρίζουν την επεξεργασία του τρέχοντος input και την αντικατάσταση του ιστορικού, παρόμοια με τις λειτουργίες που βρίσκονται στο κέλυφος Korn και στο κέλυφος GNU Bash. Αυτό υλοποιείται χρησιμοποιώντας τη βιβλιοθήκη GNU Readline, η οποία υποστηρίζει διάφορα στυλ επεξεργασίας. Αυτή η βιβλιοθήκη έχει τη δική της τεκμηρίωση που δεν θα αντιγράψουμε εδώ.

14.1. Συμπλήρωση Tab και Επεξεργασία Ιστορικού

Completion of variable and module names is automatically enabled at interpreter startup so that the Tab key invokes the completion function; it looks at Python statement names, the current local variables, and the available module names. For dotted expressions such as string.a, it will evaluate the expression up to the final '.' and then suggest completions from the attributes of the resulting object. Note that this may execute application-defined code if an object with a __getattr__() method is part of the expression. The default configuration also saves your history into a file named .python_history in your user directory. The history will be available again during the next interactive interpreter session.

14.2. Εναλλακτικές λύσεις για τον Διαδραστικό Interpreter

This facility is an enormous step forward compared to earlier versions of the interpreter; however, some wishes are left: It would be nice if the proper indentation were suggested on continuation lines (the parser knows if an indent token is required next). The completion mechanism might use the interpreter’s symbol table. A command to check (or even suggest) matching parentheses, quotes, etc., would also be useful.

Ένας εναλλακτικός, βελτιωμένος, διαδραστικός interpreter που υπάρχει εδώ και αρκετό καιρό είναι το IPython, το οποίο διαθέτει συμπλήρωση tab, εξερεύνηση αντικειμένων και προηγμένη διαχείριση ιστορικού. Μπορεί επίσης να προσαρμοστεί πλήρως και να ενσωματωθεί σε άλλες εφαρμογές. Ένα άλλο παρόμοιο βελτιωμένο διαδραστικό περιβάλλον είναι το bpython.