https://github.com/python/cpython/commit/a4760ef8e5463116b3076e0f5e3c38b314f7b20f
commit: a4760ef8e5463116b3076e0f5e3c38b314f7b20f
branch: main
author: Wim Jeantine-Glenn <[email protected]>
committer: pablogsal <[email protected]>
date: 2025-01-21T19:52:21Z
summary:

gh-128720: Fix doc inacurracy about __main__.__file__ existence in the REPL 
(#128721)

Fix doc inacurracy about __main__.__file__ existence in the REPL

files:
M Doc/library/__main__.rst

diff --git a/Doc/library/__main__.rst b/Doc/library/__main__.rst
index 647ff9da04d10d..4407ba2f7714dd 100644
--- a/Doc/library/__main__.rst
+++ b/Doc/library/__main__.rst
@@ -292,10 +292,7 @@ Here is an example module that consumes the ``__main__`` 
namespace::
         if not did_user_define_their_name():
             raise ValueError('Define the variable `my_name`!')
 
-        if '__file__' in dir(__main__):
-            print(__main__.my_name, "found in file", __main__.__file__)
-        else:
-            print(__main__.my_name)
+        print(__main__.my_name)
 
 Example usage of this module could be as follows::
 
@@ -330,7 +327,7 @@ status code 0, indicating success:
 .. code-block:: shell-session
 
    $ python start.py
-   Dinsdale found in file /path/to/start.py
+   Dinsdale
 
 Note that importing ``__main__`` doesn't cause any issues with unintentionally
 running top-level code meant for script use which is put in the
@@ -361,8 +358,5 @@ defined in the REPL becomes part of the ``__main__`` scope::
     >>> namely.print_user_name()
     Jabberwocky
 
-Note that in this case the ``__main__`` scope doesn't contain a ``__file__``
-attribute as it's interactive.
-
 The ``__main__`` scope is used in the implementation of :mod:`pdb` and
 :mod:`rlcompleter`.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to