From e36da90ad302c385437269c076deb34a9f17a754 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Fri, 19 Jan 2018 10:36:18 -0500 Subject: [PATCH] third Signed-off-by: Kenneth Reitz --- source/the-interpreter.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/the-interpreter.rst b/source/the-interpreter.rst index 5026027..da30e06 100644 --- a/source/the-interpreter.rst +++ b/source/the-interpreter.rst @@ -55,6 +55,8 @@ Note, that if you run ``pipenv shell``, its effects only last during your curren Python Interpreter Tricks ------------------------- +There are a few tricks the interpreter has up its sleeve that I recommend you utilize on a regular basis. + ``_`` Trick +++++++++++ @@ -71,15 +73,13 @@ Very useful when using the interactive interpreter! Bytecode Trick ++++++++++++++ -There are a few tricks the interpreter has up its sleeve that I recommend you utilize on a regular basis. - -The first trick is ``PYTHONDONTWRITEBYTECODE``. If you set this environment variable (e.g. in your ``~/.bashrc`` file or similar), Python won't write ``*.pyc`` files to disk, which is great, because they are incredibly annoying. +The second trick is ``PYTHONDONTWRITEBYTECODE``. If you set this environment variable (e.g. in your ``~/.bashrc`` file or similar), Python won't write ``*.pyc`` files to disk, which is great, because they are incredibly annoying. I've been using this environment variable for 7+ years for development and have never had any problems becaue of it. Interactive Mode Trick ++++++++++++++++++++++ -The second trick is to run a Python script, say ``hello.py`` in "interactive" mode, with the ``$ python -i hello.py`` flag. +The third trick is to run a Python script, say ``hello.py`` in "interactive" mode, with the ``$ python -i hello.py`` flag. This flag will run the script, like usual, but will then drop you into a REPL afterwards that has all the locals and globals from the script loaded, for your interactive pleasure. Very useful.