interpreter

PyCharm – can't use remote interpreter

PyCharm – can't use remote interpreter Question: Strange thing. I just can’t use remote interpreters. I’m 100% sure I saw it before. WTF? I have configured ssh deployment connection and vagrant box. There is nothing interesting under more button. How to add remote interpreter? edit: screenshot from settings → project → project interpreter edit2: problem …

Total answers: 5

Assigning a value to single underscore _ in Python/IPython interpreter

Assigning a value to single underscore _ in Python/IPython interpreter Question: I created this function in Python 2.7 with ipython: def _(v): return v later if I call _(somevalue), I get _ = somevalue. in[3]: _(3) out[3]: 3 in[4]: print _ out[4]: 3 The function has disappeared! If I call _(4) I get: TypeError: ‘int’ …

Total answers: 3

PyCharm. /usr/bin/python^M: bad interpreter

PyCharm. /usr/bin/python^M: bad interpreter Question: Cannot figure out, where to change EOF in PyCharm. My scripts, started with: #!/usr/bin/python # -*- coding: utf-8 -*- Outputs something like this, when I try to run it like executable (chmode +x): -bash: ./main.py: /usr/bin/python^M: bad interpreter: No such file or directory What to do and how to be? …

Total answers: 10

How do I read the output of the IPython %prun (profiler) command?

How do I read the output of the IPython %prun (profiler) command? Question: I run this: In [303]: %prun my_function() 384707 function calls (378009 primitive calls) in 83.116 CPU seconds Ordered by: internal time ncalls tottime percall cumtime percall filename:lineno(function) 37706 41.693 0.001 41.693 0.001 {max} 20039 36.000 0.002 36.000 0.002 {min} 18835 1.848 0.000 …

Total answers: 1

Is it possible to have multiple PyPlot windows? Or am I limited to subplots?

Is it possible to have multiple PyPlot windows? Or am I limited to subplots? Question: I’m not sure how to word my question more clearly. Basically, is PyPlot limited to one instance/window? Any hack or workaround I try either causes my program to freeze or for the second pyplot window to be queued until the …

Total answers: 4

How to get the current Python interpreter path from inside a Python script?

How to get the current Python interpreter path from inside a Python script? Question: I want to run a Python script from a Python script with subprocess, and I wish to do it using the same interpreter for each of them. I’m using virtualenv, so I’d like to do something like: subprocess.Popen(‘%s script.py’ % python_bin) …

Total answers: 3

How to repeat last command in python interpreter shell?

How to repeat last command in python interpreter shell? Question: How do I repeat the last command? The usual keys: Up, Ctrl+Up, Alt-p don’t work. They produce nonsensical characters. (ve)[kakarukeys@localhost ve]$ python Python 2.6.6 (r266:84292, Nov 15 2010, 21:48:32) [GCC 4.4.4 20100630 (Red Hat 4.4.4-10)] on linux2 Type “help”, “copyright”, “credits” or “license” for more …

Total answers: 26

Python Compilation/Interpretation Process

Python Compilation/Interpretation Process Question: I’m trying to understand the python compiler/interpreter process more clearly. Unfortunately, I have not taken a class in interpreters nor have I read much about them. Basically, what I understand right now is that Python code from .py files is first compiled into python bytecode (which I assume are the .pyc …

Total answers: 2

Compiled vs. Interpreted Languages

Compiled vs. Interpreted Languages Question: I’m trying to get a better understanding of the difference. I’ve found a lot of explanations online, but they tend towards the abstract differences rather than the practical implications. Most of my programming experiences has been with CPython (dynamic, interpreted), and Java (static, compiled). However, I understand that there are …

Total answers: 13