Questions tagged [python]

use for Python programming language in Emacs. Emacs supports several versions of the language implementation, versions, and coding styles. Python questions should augment with additional tags as appropriate as described in the description below.

Filter by
Sorted by
Tagged with
0
votes
1answer
101 views

py-indent-or-complete leaves the *Python Completion* buffer open

I experience when using TAB bound to py-indent-or-complete that it gives me completion suggestions. however when leaving, or deciding the completion, the *Python Completion* buffer is left open ...
1
vote
1answer
126 views

Delete marked region with py-electric-backspace py-electric-delete

In my python-mode the backspace and delete keys gets remapped to py-electric-backspace, etc. This breaks the behaviour set by the variable delete-active-region. Is there a way to unify the behaviour ...
3
votes
2answers
368 views

forward-sexp goes to eol in python mode (but only sometimes)

When I run the command forward-sexp at the beginning of the line in Python mode, my cursor jumps to the end of the line. I assume that the line is a statement, and is therefore considered to be a ...
4
votes
0answers
826 views

Org mode python session does not return a file name

In the following link you can find the following simple example: #+begin_src python :session :results file import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt fig=plt.figure(...
11
votes
3answers
2k views

How to transpose two arguments of a function in Python?

How I can I swap two arguments in a call to a Python function? If I put point on the space between these two arguments: self.assertEqual(json.loads(some.data), json_data) and then M-t (transpose-...
0
votes
0answers
579 views

how can I set a Python virtual environment in any shells (open, or that will be opened) based on changing projectile project

I'm using Projectile and pyenv-mode (https://github.com/proofit404/pyenv-mode). pyenv-mode has projectile integration to update the virtual environment while switching projects. This is the code to ...
3
votes
1answer
1k views

How to use elpy and non-python autocomplete

Elpy provides company-mode to handle autocompletion. The way it is set up, company only turns on when I am in something handled by Elpy. If I enable auto-complete it works in non-python files, but ...
0
votes
1answer
82 views

cancel outputing in pdb in emacs

In python-mode, I invoke pdb on a python script by M-x pdb script.py. I then type c to run till a breakpoint, and hit the name of a big list. It keeps on printing the content of the list in the buffer ...
5
votes
1answer
2k views

how to remove the red underline

Occasionally I have this ugly red underline in my python code. It seems not related to any flymake error/warnings. Does anyone know why it shows and how it can be removed? Thanks! I am using latest ...
0
votes
1answer
29 views

Client window hung with no visible cause

I was editing some code in an Emacs client, when all of a sudden it stopped reacting to my input. If I killed the client and connected with a new one, I got a pretty strange behaviour: if I tried to ...
0
votes
2answers
952 views

How to get cross referencing in a Python project?

I'd really like full support for cross referencing in Python, in particular in Django. I'm a bit of a n00b when it comes to emacs, but I love it dearly. I've used and been very impressed with the ada-...
0
votes
2answers
665 views

Indentation in python major mode

I am in a .py file with python major mode (syntax highlighting is working). I am trying to just use the TAB key to indent a code section. Nothing happens. Now it would be nice for emacs to do ...
9
votes
1answer
4k views

How to automatically run inferior process when loading major mode for the first time?

Let's say we are working with Python (or Matlab) with company. Without an inferior process company messages that Completion needs an inferior Python process running However, the obvious solution to ...
7
votes
1answer
1k views

How to allow org-babel to play with python virtual environment?

I have virtual environment set on my system (actually virtualenvwrapper). I would like to direct org babel to use a specific environment in a single code block or on the whole buffer. How can I do it?
2
votes
1answer
109 views

How can one quickly remove ancillary snippets of code?

How can one quickly remove ancillary snippets of code in Python scripts under Emacs? For example, for debugging purposes, I often add some print statements to print out the values of some variables. ...
2
votes
2answers
709 views

Sentence in text is read only even though the buffer is not, how to fix this?

I am running emacs 24 with the Inferior Python mode for the interpreter. See below for all the minor modes in effect. Basically the problem is that particular lines (say at the prompt) remain read-...
0
votes
1answer
351 views

Fold and select the definition of a function in python?

In python mode (the one that Emacs uses to open python script by default), can I fold the definition of a function? How can I quickly select the entire definition of a function? (so that I can copy ...
25
votes
10answers
16k views

How do use Emacs to look up a function in Python?

What is the easiest way to configure Emacs to be able to look up where a function is defined? I want to highlight it in Emacs and press a key combo to look up where the source of the function is. Can ...
2
votes
2answers
758 views

Python interactive buffer showing completions of the empty string instead of regular output

I am working with python code, and I would like to be able to evaluate it in an emacs buffer, rather than using another terminal window. I am working with the python-mode from python.el, bundled with ...
6
votes
1answer
4k views

Running two IPython instances at the same time

I'd like to run two instances of IPython in Emacs at the same time, one with Python 2, and the other Python 3: is it something doable or there's something in the way python.el is designed that would ...
2
votes
1answer
41 views

How to temporarily disable smart-operator?

I am using smart-operator for Python programming, and I like to use it. However I have also found it annoying for inputting: regular expressions like .* equals (=) in an function. I would like to ...
1
vote
1answer
2k views

Indent region in python script

I have some lines of code in a python script opened under Py Outl mode: last=-1 for i in range(len(page_nos)-1, -1, -1): if page_nos[i] != 'NULL': last = i break if last == -1: ...
70
votes
5answers
45k views

How do you create a robust Python IDE with Emacs (as the Text editor)

Emacs is an excellent editor - however it is said "to program you first need an IDE" - so how would you build an IDE in the extensively customizable Emacs for PYTHON with all the features of modern ...
4
votes
1answer
324 views

Emacs wrongly indent else expression in Python code

Say, I got a simple Python code snippet: def demo(i): if(i): print "True" else: print "False" I make indent-region for the whole buffer after save using before-save-hook in ...
0
votes
1answer
1k views

Using TAB key for indentation in Python REPL produces strange indentation problems

I'm using the Python REPL in a comint window via the run-python command, and I'm seeing bad behavior when I use the TAB key to do my indentation. For example: >>> for i in range(3): ... ...
3
votes
2answers
521 views

Wrapping Python code with %cpaste and — to send to iPython in elpy

I am loving my elpy setup in emacs, but I have one question. When I put in a ipdb.set_trace() for the ipython shell I want to send code snippets to the iPython shell. Right now my workaround is ...
3
votes
1answer
319 views

Is it possible to transform emacs to something like bpython?

bpython detects what libraries are installed and has autocompletion for codes that weren't previously written in the text, if you ever used bpython you know what I mean. Sometimes i use bpython ...
1
vote
0answers
156 views

Evil-mode text objects not working in python.el's python-mode

This only happens in python-mode. When I try to use a text object to, for example, change everything inside or around some brackets (eg ci() it instead edits the first line of the file. So if I have ...
5
votes
0answers
296 views

Ropemacs default refactoring

I'm performing a large python refactor, and one component of that is renaming many variables from camelCase to snake_case. I'd like to hook a camel-to-snake conversion function (which I already have) ...
1
vote
1answer
264 views

Debugging a “binding stack not balanced” bug?

I'm trying to figure out how to approach a bug I've run into. I assume it's actually a bug in Emacs, but I don't know the right way to make headway with it. In short, I'm getting the message "binding ...
5
votes
1answer
2k views

Where is the python.el documentation?

I am using emacs-24.3, which comes with python.el and IPython support out of the box (or so they say). Is there documentation for this mode? Where can I find it?
4
votes
2answers
5k views

Starting a virtualenv for emacs to use

I am starting a Python virtualenv through init.el (or so I would like): (require 'virtualenvwrapper) (venv-workon "my-python-project") However, flycheck does not find flake8 or pylint, which are ...
1
vote
0answers
29 views

Send pylint warning to bottom of list

When I'm using pylint-mode for a big refactor, I quite frequently want to banish lower-priority errors to the bottom of the buffer. Currently I have to skip the same errors ever time I refresh the ...
6
votes
1answer
1k views

Emacs 24's python.el + ipython cannot complete module names

I'm using Emacs 24.4.1 on OSX (installed with Homebrew), with the built in python.el, and Python 3 (also installed with Homebrew), along with IPython 2.3.0. I have this in my .emacs: (setq python-...
4
votes
1answer
1k views

Can't run Python shell in Emacs 24.4 due to a space in the path

When I try to start a Python shell in Emacs 24.4.1 running on Windows, I get an error "invalid argument" when Emacs tries to spawn the process. This is occurring because Python is installed under c:\...
3
votes
1answer
179 views

Emacs 24.4 no longer highlights keywords in `M-x run-python`

With Emacs 24.3 I get certain keywords highlighted in an inferior Python buffer: This is no longer the case for Emacs 24.4: What could possibly cause this? I've made sure it's not my configuration ...
5
votes
1answer
654 views

UnicodeDecodeError in my Inferior Python buffer

While trying to run a python script in an Inferior Python buffer for Python 3.3.5 in my Emacs 24.3.1 GTK+ window, I get a >>> Traceback (most recent call last): File "<stdin>", line ...
6
votes
3answers
996 views

prettify-symbols-mode character replacement regex

I'm using the new emacs 24.4 prettify-symbols-mode, but it isn't behaving consistently. I turn it on with: (prettify-symbols-mode t) (global-prettify-symbols-mode t) And I'm trying to change the ...
3
votes
1answer
593 views

Python and aggressive-indent

I am trying to use aggressive-indent, which I find great, but when I am writing Python code it doesn't seem to work (although general it works fine). I may miss something in the usage of aggressive-...
3
votes
1answer
1k views

highlight breakpoints with pdb

I use pdb with gud to debug python scripts. I am just wondering if there is way to highlight the lines with breakpoints? For example, in some screenshots of gud-gdb, some people seem to have red ...
2
votes
1answer
2k views

Python mode - bypassing dialogue on C-c C-c, and having Python appear in its own frame

Whenever I'm in Python mode and do C-c C-c, I have to answer two questions - firstly, what command to run (which defaults to /usr/bin/python2 -i for me) and secondly, whether I want a dedicated ...
1
vote
0answers
392 views

Python-emacs communication broken

When I call run-python, I get the buffer with python REPL and the prompt. I can type stuff, but when I press enter there is no reaction (except the cursor moves in new line). If I press C-c C-c (...
3
votes
1answer
75 views

How can I enable my modifications to a library/package without modifying its source?

I have been using a forked version of python.el for some time in which I have changed the indentation rules so that instead of something.method1()\ .method2() and stuff = (1, 2, 3, ...
11
votes
1answer
4k views

python auto indent problem

I'm using Emacs 24.4. When writing Python code, Emacs behaves strangely with respect to indentation. For example: for i in range(10): print(i) for i in range(10) When I input :, Emacs adds a ...
14
votes
1answer
3k views

Display errors and warnings in an org-mode code block

I would like to be able to report warnings and errors when evaluating a Python code block in an Org file. When a code block has Python syntax errors, Org helpfully pops them up in a separate ...
15
votes
2answers
3k views

Can I include a common code block in two different code blocks in Org mode?

I have an org-mode file containing a table of data and two Python code blocks to extract different summaries from it. I would like to share some common constants and functions between these two code ...
6
votes
1answer
4k views

eldoc in python-mode

I'm trying to get eldoc-mode to work in python-mode. If I enter a python buffer and do M-x eldoc-mode M-x python-mode-switch-to-shell This seems to work for some built-in functions, but mostly ...
16
votes
2answers
1k views

Make fill-paragraph in python docstring leave the triple-quotes on separate line

I type a python docstring all on one line like this: """ This is a long docstring. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas ...
3
votes
0answers
284 views

Undesired auto expansion with company-mode and python-mode

I am using company-mode and python-mode (note the same issue does not happen with python.el) and something about the combination is causing emacs to automatically expand at point. For example, if I ...
7
votes
1answer
692 views

How can I prevent python-mode from occasionally highlighting everything as string

I use python-mode for my Python code, and every once in a while the syntax highlighter gets confused and thinks everything in the buffer is a string literal. This typically seems to happen when I ...

1
7 8 9
10
11