Questions tagged [python-interactive]
158 questions
78
votes
1 answer
What is the meaning of a forward slash "/" in a Python method signature, as shown by help(foo)?
In the signature returned interactively by help(foo), what is the meaning of a /?
In [37]: help(object.__eq__)
Help on wrapper_descriptor:
__eq__(self, value, /)
Return self==value.
In [55]: help(object.__init__)
Help on…

gerrit
- 24,025
- 17
- 97
- 170
37
votes
4 answers
Randomly change the prompt in the Python interpreter
It's kind of boring to always see the >>> prompt in Python. What would be the best way to go about randomly changing the prompt prefix?
I imagine an interaction like:
This is a tobbaconist!>> import sys
Sorry?>> import math
Sorry?>> print…

mircealungu
- 6,831
- 7
- 34
- 44
22
votes
10 answers
Why use Python interactive mode?
When I first started reading about Python, all of the tutorials have you use Python's Interactive Mode. It is difficult to save, write long programs, or edit your existing lines (for me at least). It seems like a far more difficult way of writing…

Mantas Vidutis
- 16,376
- 20
- 76
- 92
20
votes
5 answers
How to get a python script to invoke "python -i" when called normally?
I have a python script that I like to run with python -i script.py, which runs the script and then enters interactive mode so that I can play around with the results.
Is it possible to have the script itself invoke this option, such that I can just…

Matthew Moisen
- 16,701
- 27
- 128
- 231
18
votes
2 answers
Why does typing a variable (or expression) print the value to stdout?
Take this example:
>>> 5+10
15
>>> a = 5 + 10
>>> a
15
How and why does Python do this without an explicit print statement?
If I do the same thing in an IPython cell, only the last such value is actually printed on stdout in this way:
In[1]: 5+10
…

Chayan Ghosh
- 718
- 5
- 18
14
votes
3 answers
Hosting interactive jupyter notebook on private website
I currently run a personal website using Wordpress (but hosted on siteground) that is a set of engineering study guides. I would like to move towards making these study guides interactive (i.e. refreshing graphics based on sliders, doing basic…

stagermane
- 1,003
- 2
- 12
- 29
10
votes
1 answer
Where does Python's interactive prompt ">>>" output to?
I've run into a somewhat unusual situation. I'm trying to script the interactive console (for teaching/testing purposes), and I tried the following:
$ python > /dev/null
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple…

nneonneo
- 171,345
- 36
- 312
- 383
8
votes
1 answer
Visual Studio Code with Jupyter Notebook: Shortcut for “run all”?
I have python script with jupyter notebook mark #%% which describe that I can run this script in visual studio code python interactive.
Acccording to this:
Jupyter/IPython Notebooks: Shortcut for "run all"?
I have similar question because…

ElConrado
- 1,477
- 4
- 20
- 46
8
votes
1 answer
Simple if statement on python interpreter
Environment:
Fedora 27 (GNU/Linux)
terminal
python3.6.3
I am having problems running this simple lines of code in the python interpreter, this is an only if statement or alone if statement.
n = 5
if n == 4:
print('n=4')
print('done')
This…

christianbueno.1
- 516
- 1
- 8
- 12
7
votes
1 answer
VS Code "Run selection/line in Python interactive window" not working at all
On a new install of VS Code on a new machine I have come across this error.
The send to python interactive window functionality is behaving exceptionally weirdly.
It will:
- Send a single line of code to the interactive window using either…

Robert Franklin
- 160
- 1
- 1
- 7
7
votes
3 answers
VS Code with Jupyter's interactive window: How to change the syntax colors in Python Interactive window (some text is unreadable on dark themes)?
I'm using VS Code with the Jupyter's Python Interactive window so that I can run individual cells and get the output, figures etc. in the Python Interactive window.
However, some of the colors are unreadable on darker themes, for example see the…

KMFR
- 895
- 1
- 15
- 24
6
votes
1 answer
Matplotlib while debugging in Pycharm: How to turn off interactive mode?
First of all, I am working on the Pycharm debug console and want to put a caption under my diagram. According to this answer this can be achieved by:
plt.plot([2,5,1,2]
fig = plt.figure()
fig.text(.5, .05, "text", ha="center")
plt.show()
However,…

PeterHeuz
- 390
- 1
- 4
- 17
6
votes
1 answer
Why does "a is b" behave differently on Interactive mode and when it's ran from script?
While trying to answer a question about the use of the is keyword, I figured out that this code:
Script:
a = 123456
b = 123456
print a is b # True
Interactive mode:
>>> a = 123456
>>> b = 123456
>>> a is b
False
was giving different outputs on…

Christian Tapia
- 33,620
- 7
- 56
- 73
6
votes
1 answer
Is it possible to get the Python Interactive Interpreter to run a script on load?
When working on a project my scripts often have some boiler-plate code, like adding paths to sys.path and importing my project's modules. It gets tedious to run this boiler-plate code every time I start up the interactive interpreter to quickly…

Hubro
- 56,214
- 69
- 228
- 381
5
votes
2 answers
Interactively add and remove scatter points in matplotlib
Here is the problem I would like to solve:
I would like to be able to interactively (i) remove scatter points (grey dots), (ii) add new scatter points, by clicking on the plot.
import matplotlib.pyplot as plt
import numpy as np
fig, ax =…

themachinist
- 1,413
- 2
- 17
- 22