IPython not throwing IndentationError with unexpected indent
{'commit_hash': 'e508b6e4d', 'commit_source': 'installation', 'default_encoding': 'UTF-8', 'ipython_path': '/home/geniuslearner/.local/lib/python3.7/site-packages/IPython', 'ipython_version': '7.10.1', 'os_name': 'posix', 'platform': 'Linux-4.19.0-6-amd64-x86_64-with-debian-10.2', 'sys_executable': '/usr/bin/python', 'sys_platform': 'linux', 'sys_version': '3.7.3 (default, Apr 3 2019, 05:39:12) \n[GCC 8.3.0]'}
Actual problem: Whitespace in the beginning of the line throws IndentationError in Python.
But, in IPython, it is not showing indentation error.
>>> a = 12
>>> a = 12
File "<stdin>", line 1
a = 12
^
IndentationError: unexpected indent
I want to also fix this issue. Please point me to the relevant code.
That's on purpose, to allow you to past code – usually from website – that may have extra whitespace or prompt in it:
In [1]: In [3]: a = 1
...: ...: b = 2
In [2]: >>> i = 1
It will throw UnexpectedIndent if the amount of whitespace is not consistent between line.
In [3]: a = 1
...: b = 2
File "<ipython-input-7-8e872b00334f>", line 2
b = 2
^
IndentationError: unexpected indent
But unless it's actually crating bugs in legitimate case, it's an on purpose feature.
Closing, but feel free to ask to reopen if there is something I missed.