admin管理员组文章数量:1399278
So, I was programming in the IDE Spyder, and typed in import a
by accident (I meant to type import math
). Anyways, it threw up this XKCD page.
At first I was a bit baffled and then got concerned. After doing some digging, it turns out if you run the code import antigravity
it opens that very page (and this command is actually referenced on that page). I guess this is just some sort of funny easter egg.
But you can imagine, just typing in import a
, not knowing anything about this easter egg and getting a random webpage thrown up threw me off.
You can replicate this very easily. Close the Spyder program, open it up, type in import a
and it'll automatically throw up that webpage. It doesn't do it after if you retype it, you have to have just opened up the program.
What's going on in the background? Is Spyder automatically loading in all the possible modules that begin with a
or something?
So, I was programming in the IDE Spyder, and typed in import a
by accident (I meant to type import math
). Anyways, it threw up this XKCD page.
At first I was a bit baffled and then got concerned. After doing some digging, it turns out if you run the code import antigravity
it opens that very page (and this command is actually referenced on that page). I guess this is just some sort of funny easter egg.
But you can imagine, just typing in import a
, not knowing anything about this easter egg and getting a random webpage thrown up threw me off.
You can replicate this very easily. Close the Spyder program, open it up, type in import a
and it'll automatically throw up that webpage. It doesn't do it after if you retype it, you have to have just opened up the program.
What's going on in the background? Is Spyder automatically loading in all the possible modules that begin with a
or something?
- 2 You're right about the easter egg. There are several in Python. – Friedrich Commented Mar 25 at 13:49
- The reason it doesn't work a second time is that modules are cached by Python. The second import doesn't load it again, it just gives you another reference to the same module. – Mark Ransom Commented Mar 25 at 14:13
1 Answer
Reset to default 0I think the only way this could happen is if you have a module a
in your path somewhere, and it does an import antigravity
somewhere within it. It seems unlikely but it's the only explanation that fits.
本文标签: pythonWhy does quotimport aquot give me an XKCD page in SpyderStack Overflow
版权声明:本文标题:python - Why does "import a" give me an XKCD page in Spyder? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744193221a2594618.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论