Ask Your Question
0

"unindent does not match ..." error

asked 2019-04-27 16:48:40 +0200

stockh0lm gravatar image

updated 2019-04-27 17:03:07 +0200

so i started coding in python inside sage. yay.

this is my code that bombs:

def cable_from_pc_list(pc_list):
 xo, xd, zo, zd = var('xo xd zo zd')
 o, d = var('o d')
 o = vector([xo, zo])
 d = vector([xd, zd])

for i in pc_list:
    o = i['origin']
    d = i['dest']
    q = i['charge']
    s1 = o - d
    s2 = -s1/abs(s1) * (R^2/abs(s1))
    show(d + s2)

and surprisingly it throws this error:

sage: load('/home/andreas/src/dissertation/analytical/demo.sage')
  File "<string>", line 8
    for i in pc_list:
                     ^
IndentationError: unindent does not match any outer indentation level

This is in a single file, the only code, in a fresh sage process. There are no tabs in that file, and the indention is consistent (4 spaces).

i googled for python help and found out about the "set up your environment and editor correctly", which i made sure of. I use emacs and with help of whitespace-mode i made sure of the indention and tab-freeness. Please help me fix this.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-04-27 18:40:12 +0200

stockh0lm gravatar image

the indentation is messed up above, but the problem was that the lines before the problematic line were indentet with five spaces, and then the for in in ... line was indentet with four.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-04-27 16:48:40 +0200

Seen: 301 times

Last updated: Apr 27 '19