“导入这个”和“垃圾人”激发的幽默感_
theword的Python项目详细描述
灵感来自python的import this、The Trashmen和The Family Guy,theword 是一个古怪的图书馆来回答那个永恒的问题,“这个词是什么?”?“。”
安装
从任何命令行:
$ pip install theword
模拟python的禅
从任何命令行:
$ python -c "import theword" _Surfin' Bird_, by The Trashmen A well a everybody's heard about the bird Bird, bird, bird, b-bird's the word A well a bird, bird, bird, b-bird's the word A well a bird, bird, bird, b-bird's the word A well a bird, bird, b-bird's the word
一般用法
您可以导入以下任意项:
fromthewordimportTheWord,TheBird,what_is_the_word
提出问题:
>>>what_is_the_word()<theword.theword.TheBirdobjectat0x10f582d90># Returns TheBird>>>what_is_the_word().answer'[E]verybody knows that the bird is the word!'>>>printwhat_is_the_word()# We overloaded __str__{"answer":"[E]verybody knows that the bird is the word!","question":"What's the word?","id":"The Bird"}
更有趣的是:
>>>what_is_the_word().play()# Turn on the volume, ensure your WiFi is on{'artist':'The Trashmen','title':"Surfin' Bird",'question':"What's the word?",'released':1964,'answer':'[E]verybody knows that the bird is the word!','id':'The Bird'}>>>what_is_the_word().celebrate()# Be prepared to laugh{'answer':'[E]verybody knows that the bird is the word!','celebrated_on':"FOX's The Family Guy",'question':"What's the word?",'id':'The Bird','celebrated_by':'Seth MacFarlane'}>>>
如果你看了所有的小品,你会认出这个:
Sir, our math shows that the Bird is greater than or equal to the Word!
>>>isinstance(TheBird(),TheWord)True>>>issubclass(TheBird,TheWord)True