You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Importing __hello__ or __phello__ on Python 3.7-3.10 prints "Hello world!"
Importing __hello__ or __phello__ on Python 3.11-3.12 prints nothing.
$ python3.7
Python 3.7.13 (default, Jul 8 2022, 20:05:46)
[Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __hello__
Hello world!
>>> import __phello__
Hello world!
>>>
$ python3.8
Python 3.8.13 (default, Apr 26 2022, 16:12:31)
[Clang 13.1.6 (clang-1316.0.21.2.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __hello__
Hello world!
>>> import __phello__
Hello world!
>>>
$ python3.9
Python 3.9.13 (main, May 24 2022, 21:13:51)
[Clang 13.1.6 (clang-1316.0.21.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __hello__
Hello world!
>>> import __phello__
Hello world!
>>>
$ python3.10
Python 3.10.6 (main, Aug 30 2022, 04:58:14) [Clang 13.1.6 (clang-1316.0.21.2.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __hello__
Hello world!
>>> import __phello__
Hello world!
>>>
$ python3.11
Python 3.11.1 (v3.11.1:a7a450f84a, Dec 6 2022, 15:24:06) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __hello__
>>> import __phello__
>>> ^D
$ python3.12
Python 3.12.0a3 (v3.12.0a3:b6bd7ffcbc, Dec 6 2022, 15:26:51) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __hello__
>>> import __phello__
>>> ^D
And at least as early as 3.11.0a2:
$ ./python.exe
Python 3.11.0a2 (tags/v3.11.0a2:e2b4e4bab9, Dec 9 2022, 16:19:07) [Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __phello__
>>> import __hello__
>>>
The behavior was intentionally changed by issue #89182 and pull request #28374. __hello__ and __phello__.spam still print to sys.stdout when run as scripts. When imported, main() has to be called. For example:
Activity
eryksun commentedon Dec 9, 2022
The behavior was intentionally changed by issue #89182 and pull request #28374.
__hello__and__phello__.spamstill print tosys.stdoutwhen run as scripts. When imported,main()has to be called. For example:hugovk commentedon Dec 9, 2022
Okay, thanks.
I saw the old, short and simple version on a list of Python Easter eggs:
https://github.com/OrkoHunter/python-easter-eggs
And searching for Python Easter eggs it often shows up as the first one such as 'The Easiest “Hello World”':
It's less exciting in the new form.
But fine by me if you'd like to close this as correct behaviour.
eryksun commentedon Dec 9, 2022
At least
import thisstill prints the text of "The Zen of Python".zware commentedon Dec 9, 2022
How badly would it break the tests that depend on
__hello__to also callmain()ifsys.ps1has a value? Is it worth saving the easter egg? :)