An Emacs mode for editing Python code

Unusual indentation after assigning a list to a variable

Asked by Alejandro Weinstein on 2012-12-06

Hi:

I am observing an unusual behavior of the code indentation after a assigning a list to a variable. The following code illustrates the issue:

a = 1
# After pressing enter, next line starts at column 1, as expected
b = [1]
    # After pressing enter, next line starts at column 4

I'm using the last revision of python-mode.

Is there any explanation for this behavior?

Alejandro

Question information

Language:
English Edit question
Status:
Solved
For:
python-mode.el Edit question
Assignee:
No assignee Edit question
Last query:
2012-12-06
Last reply:
2012-12-16
Andreas Roehler (a-roehler) said : #1

Am 06.12.2012 16:35, schrieb Alejandro Weinstein:
> New question #216104 on python-mode.el:
> https://answers.launchpad.net/python-mode/+question/216104
>
> Hi:
>
> I am observing an unusual behavior of the code indentation after a assigning a list to a variable. The following code illustrates the issue:
>
> a = 1
> # After pressing enter, next line starts at column 1, as expected
> b = [1]
> # After pressing enter, next line starts at column 4
>
> I'm using the last revision of python-mode.
>
> Is there any explanation for this behavior?
>
> Alejandro
>

If the comment was indented, yes.

Comments might be indented or not indented.
When indented, following C-j expects it indented correctly, resp. deliberated.
Next line will follow that previous decision.

Should you think it will be convenient otherwise, please file a feature request at the bugs slot.

Andreas

> If the comment was indented, yes

I added the comments just to explain the behavior.

I observe the same without comments, and only if the assigment is a list, tuple or dictionary.

Alejandro.

Andreas Roehler (a-roehler) said : #3

fix for Bug #1087404: wrong indent after asignment
has been commited

Flagging this as "solved"

Andreas Roehler (a-roehler) said : #4

fix commited