File tree Expand file tree Collapse file tree 1 file changed +2
-8
lines changed Expand file tree Collapse file tree 1 file changed +2
-8
lines changed Original file line number Diff line number Diff line change @@ -292,10 +292,7 @@ Here is an example module that consumes the ``__main__`` namespace::
292292 if not did_user_define_their_name():
293293 raise ValueError('Define the variable `my_name`!')
294294
295- if '__file__' in dir(__main__):
296- print(__main__.my_name, "found in file", __main__.__file__)
297- else:
298- print(__main__.my_name)
295+ print(__main__.my_name)
299296
300297Example usage of this module could be as follows::
301298
@@ -330,7 +327,7 @@ status code 0, indicating success:
330327.. code-block :: shell-session
331328
332329 $ python start.py
333- Dinsdale found in file /path/to/start.py
330+ Dinsdale
334331
335332 Note that importing ``__main__ `` doesn't cause any issues with unintentionally
336333running 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::
361358 >>> namely.print_user_name()
362359 Jabberwocky
363360
364- Note that in this case the ``__main__ `` scope doesn't contain a ``__file__ ``
365- attribute as it's interactive.
366-
367361The ``__main__ `` scope is used in the implementation of :mod: `pdb ` and
368362:mod: `rlcompleter `.
You can’t perform that action at this time.
0 commit comments