-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Swap __name__
to something other than __main__
in Python REPLs
#540
Comments
Would deleting the
In part 6, Modules, in the Python Tutorial it says:
|
Rather than deleting (just in case someone is assuming that it'll exist and be a string) I've set |
That should provide less surprise. Thanks! |
As a few people have been discussing on Discord, the Python REPL leaves
__name__
bound to the default__main__
which means your__main__
block is run when you load a buffer into the REPL. This is pretty unintuitive and probably dangerous.We should bind
__name__
to__repl__
or maybe even the name of the Python module you're currently editing if that can always be cleanly inferred. Looking at what other tooling does here may also be helpful especially if people already have expectations about how this should work from other tools.The text was updated successfully, but these errors were encountered: