Questions tagged [python-interactive]

158 questions
5
votes
2 answers

How do I retrieve the output of a previous command and save it in a variable inside the Python interactive shell?

Say I ran an expensive operation foo() which returns me a large list, but I forgot to save the output of foo() inside a variable. Let's assume if I run foo() again, I will get a different output. But I really need the output from the first time I…
n00shie
  • 1,741
  • 1
  • 12
  • 23
4
votes
2 answers

Virtual Environment Activation from Command Prompt Returns "The system cannot find the path specified" but Activates Venv Anyway?

I created a virtual environment in a Windows terminal using the standard: python -m venv {venv name} Everything works as far as I can tell, but when I change into the "Scripts" directory and run "activate" (or even ".\activate"), I get the message…
4
votes
3 answers

Python interpreter segfault

I have strange problem, when I run python shell: $ python3 Python 3.4.2 (default, Oct 8 2014, 10:45:20) [GCC 4.9.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> print('Hello') # Error appears for any command…
Anton Linevych
  • 647
  • 1
  • 7
  • 25
4
votes
2 answers

print greeting message when entering python interpreter

How do I print a greeting message when I initialize a python interpreter? For example, if I were to initialize a python interpreter with custom pre-defined variables, how might I advertise those variables to the user?
Walrus the Cat
  • 2,314
  • 5
  • 35
  • 64
4
votes
2 answers

Updating pyplot.vlines in interactive plot

I need your help. Please consider the code below, which plots a sinusoid using pylab in IPython. A slider below the axis enables the user to adjust the frequency of the sinusoid interactively. %pylab # setup figure fig, ax =…
MaxPowers
  • 5,235
  • 2
  • 44
  • 69
4
votes
1 answer

python interative mode does not work when reading from std in

Given the following python script.... $ cat readStdin.py #!/usr/bin/python import sys var = "".join(sys.stdin.readlines()).rstrip() print var ... I get the follwing output: $ echo hello | python -i readStdin.py hello >>> $ ... in other…
murungu
  • 2,090
  • 4
  • 21
  • 45
3
votes
1 answer

Why does my code work from interactive shell, but not when run from a file?

I am trying to use the pprint module to check out some vars in Python, which I can happily do using the interactive shell and the code below: import pprint pp = pprint.PrettyPrinter() stuff = ['cakes','bread','mead'] pp.pprint(stuff) However, when…
ben
  • 1,583
  • 2
  • 11
  • 12
3
votes
1 answer

Customize "Python Interactive" Window in VS Code

Is there a way to customize (e.g., JSON config) the 'Python Interactive' Window to iPython/Jupyter console that comes with the MS Python extension? I would like to be able to adjust the size of the variable explorer pane within the window (it can't…
secJ
  • 499
  • 3
  • 12
3
votes
2 answers

Why is the escape character sometimes output in the interactive interpreter of Python?

If I type this in the interactive interpreter of Python: >>> 'doesn\'t' "doesn't" >>> '"Isn\'t," they said.' '"Isn\'t," they said.' Why is the escape character (\) printed in the second case? I realize that I can use the print() function to escape…
jalalhugo
  • 65
  • 5
3
votes
0 answers

How to fix 'StdinNotImplementedError' in python interactive in Visual Studio Code

I'm using Visual Studio Code (1.34.0) and Python extension by microsoft for python coding. I tried using the input() function in the Python Interactive window and got an error 'StdinNotImplementedError'. Error StdinNotImplementedError …
3
votes
2 answers

In Python, how could I shell out and interact with an external program (say vi or nano) and return to python

My first question on stackoverflow! I'm trying to figure out how I can start an external program that requires the user to interact with it, say vi, nano, ssh, telnet etc. and return to the Python script when the program exits. I don't want to use…
jamdoran
  • 41
  • 3
3
votes
1 answer

Equivalent of Ipython run command in normal python

I'm trying to run a program using spyder instead of ipython notebook because it currently runs faster. The data is imported and extracted using run util/file_reader.py C:/file_address Obviously the run command doesn't work in normal python and I…
aml
  • 137
  • 9
3
votes
2 answers

designing python api. reliable cleanup vs easy-to-use in interpreter

I'm working on a design of the python-based API. At the moment I've met an issue with two divergent requirements. On the one side I would like to provide reliable way to cleanup API-related resources. Thus as I know the best way to do it is to use…
3
votes
0 answers

cursor control for "python -i" in cygwin

When using python in cygwin, you need to use "python -i" to get into interactive mode. This mode however removes my ability to use my arrow keys to go through my history. When I push the Up-Key, the cursor goes up. When I press DELETE, the…
Vjeetje
  • 5,314
  • 5
  • 35
  • 57
2
votes
1 answer

Weird behaviors on interactive imshow plot in Python

I'm trying to construct a grid of black squares, and everytime you click on one it turns white. Now for some reason my code does very weird things: The coordinates I input doesn't correspond to the array coordinates. I tried to change that by…
Chris Ze Third
  • 632
  • 2
  • 18
1
2
3
10 11