0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python > import this > Easter eggを表示する > オンラインコード実行環境で試した

Last updated at Posted at 2017-01-09

@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic
(No. 432 / 12833)

import thisというのが掲載されていた。

@ paiza

https://paiza.io/?locale=ja-jp
にて「コード作成を試してみる(無料)」で実行。

// Here your code !
import this

print("XXXXXXXX")

~~```txt:結果
main.swift:2:8: error: no such module 'this'
import this


(追記 2017/01/09)
@nukorouさんに確認いただきましたように、paizaでもEaster eggが表示されました。


### @ ideone > Python (version 2?)

http://ideone.com/q2dtSc

```py
# your code goes here
import this
結果
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

@ codinggroundのPython実行環境

# Hello World program in Python

import this
    
print "Hello World!\n"
結果
sh-4.3$ python main.py                                                                                                                
The Zen of Python, by Tim Peters                                                                                                      
                                                                                                                                      
Beautiful is better than ugly.                                                                                                        
Explicit is better than implicit.                                                                                                     
Simple is better than complex.                                                                                                        
Complex is better than complicated.                                                                                                   
Flat is better than nested.                                                                                                           
Sparse is better than dense.                                                                                                          
Readability counts.                                                                                                                   
Special cases aren't special enough to break the rules.                                                                               
Although practicality beats purity.                                                                                                   
Errors should never pass silently.                                                                                                    
Unless explicitly silenced.                                                                                                           
In the face of ambiguity, refuse the temptation to guess.                                                                             
There should be one-- and preferably only one --obvious way to do it.                                                                 
Although that way may not be obvious at first unless you're Dutch.                                                                    
Now is better than never.                                                                                                             
Although never is often better than *right* now.                                                                                      
If the implementation is hard to explain, it's a bad idea.                                                                            
If the implementation is easy to explain, it may be a good idea.                                                                      
Namespaces are one honking great idea -- let's do more of those!                                                                      
Hello World!                                                                                                                          
                                                                                                                                      
sh-4.3$                                      

@ codinggroundのbash実行環境

  • 手順
    • pythonと入力
    • import thisと入力 (Easter eggが表示される)
    • quit()で終了

備考

Python実装方法の違いが出る。
(内部の具体的な実装方法は不明だが)。

上記すべてでEaster eggが表示されました。

意図的に特定のimportをできないようにしているオンラインコード実行環境もある、という記事を見たことがある。

0
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?