Skip to content

Jupyter Not Supported Standard Python Scripts Rule #7630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
neerajpatel2505 opened this issue Apr 12, 2025 · 2 comments
Closed

Jupyter Not Supported Standard Python Scripts Rule #7630

neerajpatel2505 opened this issue Apr 12, 2025 · 2 comments
Labels
bug status:Needs Triage Applied to issues that need triage

Comments

@neerajpatel2505
Copy link

In standard Python scripts (.py files):

If the first line starts with an unexpected indent (a space or tab), Python will raise an IndentationError.
Example:
print("Hello")
This gives:
IndentationError: unexpected indent
Python expects top-level code to start at column 0 unless it's inside a block (like a function or loop). So that space is a no-no outside of those.

But in Jupyter Notebook:

Jupyter is more forgiving — it allows leading spaces in the first line of a cell even if the code is at the top level. It doesn't strictly enforce indentation rules the way a .py file would when executed.

@neerajpatel2505 neerajpatel2505 added bug status:Needs Triage Applied to issues that need triage labels Apr 12, 2025
@danyeaw
Copy link

danyeaw commented Apr 15, 2025

Hi @neerajpatel2505, thanks for submitting the issue. We can reproduce this in IPython directly which executes the cells in Notebook. I think the forgiveness to indention might be on purpose, but you could open a new issue in the IPython repo to discuss it or request an option to disable this current functionality.

@neerajpatel2505
Copy link
Author

Hi @danyeaw, thanks for your valuable response.
Your clarification makes sense — I’ll go ahead and open an issue in the IPython repo to take the discussion further.

Thanks for the clarification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status:Needs Triage Applied to issues that need triage
Projects
None yet
Development

No branches or pull requests

2 participants