最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Why does "import a" give me an XKCD page in Spyder? - Stack Overflow

programmeradmin5浏览0评论

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?

Share Improve this question edited Mar 25 at 13:57 General Grievance 5,04338 gold badges37 silver badges56 bronze badges asked Mar 25 at 13:26 Riemann'sPointyNoseRiemann'sPointyNose 1171 silver badge1 bronze badge 2
  • 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
Add a comment  | 

1 Answer 1

Reset to default 0

I 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.

发布评论

评论列表(0)

  1. 暂无评论