You are not logged in.
It seems that many, if not most people nowadays use IPython instead of the default Python interpreter. I've used it briefly in the past but, while I found a few features to be useful, such as the persistent command history and tab-completion, I found it to be otherwise quite bloated with features that I would never use (and which, furthermore, employ a strange and non-Pythonic meta-syntax).
It appears to be an under-appreciated fact that you can run a script automatically when you launch the default Python interpreter. I certainly did not know about it for some time. Using this feature, I've found that I can implement a few extra features in the standard Python interpreter that greatly improve its usage (for me), without going full hog with other bloat.
The script's available on Github. To use it, just set your PYTHONSTARTUP environment variable to point to it.
It's compatible with both Python 2 and 3
Features
pre-loaded modules & functions: sys, os.path, print function (python 2) and pprint function
persistent command history: you can access commands entered during previous interaction sessions
colorized, command history-aware prompts: display the current position in the history file, in green at the default prompt and in yellow at a continuation prompt
syntax-highlighted tab-completion: tab-complete commands while they're being entered, with the completion results highlighted according to their syntactic function (i.e. modules in yellow, functions in blue, etc)
indentation keyboard shortcuts: indent the current line with "ctrl-j" and unindent with "ctrl-u". You can use these even when the cursor is in the middle of a line of text and it will do as you expect
context-specific auto-indentation: upon beginning to type on a new line, automatically indent to the syntactically correct indentation level
printable functions: provide the "saved_function" function decorator, which allows you to later view the function definition via the print function
Here's an example illustrating the last one:
# As an argument, pass the line number where the function definition will begin
[23]> @saved_function(24)
(23)> def foo(bar):
(23)> print(bar)
[26]> print(foo)
def foo(bar):
print(bar)
See the README file for a much more verbose description.
Last edited by jakobcreutzfeldt (2014-03-22 15:38:54)
Offline