[Python-ideas] Python hook just before NameError
Steven D'Aprano
steve at pearwood.info
Mon Dec 29 14:31:17 CET 2014
On Mon, Dec 29, 2014 at 07:46:02AM +0000, Mark Lawrence wrote:
> +1 from me as I'm always forgetting the "obvious" imports such as sys
> and os when trying things interactively.
This is why I have a startup.py file that contains (among other things):
import sys, os
I'm not sure how you set environment variables under Windows, but under
Linux I put this in my .bashrc file:
export PYTHONSTARTUP=/home/steve/python/utilities/startup.py
and whenever I start an interactive session, I get the common imports
that I want, a custom prompt (I use 'py>' rather than '>>>') and
assorted other goodies.
--
Steven
More information about the Python-ideas
mailing list