[Python-Dev] PYTHON3PATH
Ralf Schmitt
ralf at brainbot.com
Wed Jan 13 21:52:34 CET 2010
Lennart Regebro <regebro at gmail.com> writes:
> On Wed, Jan 13, 2010 at 18:40, Ralf Schmitt <ralf at brainbot.com> wrote:
>> The first thing I got while trying to run a python3 prompt few days ago,
>> was an error. python3 tried to read my $PYTHONSTARTUP file, which used
>> print statements. people will have to run both python 2 and python 3
>> code at the same time. Using different environment variables will make
>> this easier.
>
> What do you need to do in the PYTHONSTARTUP file?
> Ten years of Python programming, and I didn't even know it existed. :-)
hehe. tab completion:
# -*- mode: python -*-
# Last changed: 2009-12-23 22:25:15 by ralf
import sys
import os
def initreadline():
try:
import readline
except ImportError:
sys.stdout.write("Module readline not available.\n")
return
import rlcompleter
readline.parse_and_bind("tab: complete")
# Use tab for completions
readline.parse_and_bind('tab: complete')
# This forces readline to automatically print the above list when tab
# completion is set to 'complete'.
readline.parse_and_bind('set show-all-if-ambiguous on')
# Bindings for incremental searches in the history. These searches
# use the string typed so far on the command line and search
# anything in the previous input history containing them.
readline.parse_and_bind('"\C-r": reverse-search-history')
readline.parse_and_bind('"\C-s": forward-search-history')
history = os.path.expanduser("~/.pyhistory")
if os.path.exists(history):
readline.read_history_file(history)
import atexit
atexit.register(lambda: readline.write_history_file(history))
initreadline()
del initreadline
More information about the Python-Dev
mailing list