First time here? Check out the FAQ!
-1

Let Python Shell do the indentation correctly.

Hi,

Currently, the Python Shell can't indent codes input there correctly. Could you please add this feature for wing?

Regards, HY

hongyi-zhao's avatar
547
hongyi-zhao
asked 2020-09-23 05:21:21 -0600
Wingware Support's avatar
4.2k
Wingware Support
updated 2020-09-23 09:11:46 -0600
edit flag offensive 0 remove flag close merge delete

Comments

Could you give us an example of what isn't working for you?

Wingware Support's avatar Wingware Support (2020-09-23 08:17:26 -0600) edit

Example:

for i in range(5):
            print(i)

Result:

Traceback (most recent call last):
  Python Shell, prompt 1, line 2
builtins.IndentationError: expected an indented block (2, line 2)
hongyi-zhao's avatar hongyi-zhao (2020-09-23 18:09:00 -0600) edit
add a comment see more comments

2 Answers

0

Indentation means the space from margin to the begin of characters in a line. Python language is a very sensitive language for indentation, it has caused confusion for many beginners. Putting in an extra space or leaving one out where it is needed will surely generate an error message . Some common causes of this error include:

  • Forgetting to indent the statements within a compound statement.
  • Forgetting to indent the statements of a user-defined function.

The error message IndentationError: expected an indented block would seem to indicate that you have an indentation error. It is probably caused by a mix of tabs and spaces .

leneborma's avatar
1
leneborma
answered 2021-08-26 00:20:08 -0600
edit flag offensive 0 remove flag delete link

Comments

I think the original question was why the Python Shell didn't auto-indent correctly. The answer is that it should, and we'd appreciate any examples where it does not.

Wingware Support's avatar Wingware Support (2021-08-26 09:41:27 -0600) edit
add a comment see more comments
0

This seems to work for me. I may be confused due to the messed up formatting your comment had due to the slightly braindead options in this forum. I tried to fix that by editing it; I thought at first maybe 'print(i)' was not indented but it seemed to be. If it were not indented, this is not really something we can fix since moving relative indents within a pasted block has cases where there's ambiguity. However, we do re-indent pasted blocks of code in the shells so it removes any leading indent before all the lines. The bottom line is we may need further clarification on this one.

Wingware Support's avatar
4.2k
Wingware Support
answered 2020-10-05 10:05:19 -0600
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer