<br><br><div class="gmail_quote">On Tue, Jul 13, 2010 at 05:48, Nick Coghlan <span dir="ltr"><<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Tue, Jul 13, 2010 at 10:37 AM, Alexander Belopolsky<br>
<<a href="mailto:alexander.belopolsky@gmail.com">alexander.belopolsky@gmail.com</a>> wrote:<br>
> In my experiments, 0 is not equivalent to None:<br>
><br>
>>>> import sys, time<br>
>>>> sys.modules['time'] = 0<br>
>>>> __import__('time')<br>
> 0<br>
>>>> sys.modules['time'] = None<br>
>>>> __import__('time')<br>
> Traceback (most recent call last):<br>
> File "<stdin>", line 1, in <module><br>
> ImportError: No module named time<br>
><br>
> Am I missing something?<br>
<br>
</div>I don't think so. I suspect I got away with this mistake because the<br>
imports I was trying to block in the test suite were all C<br>
acceleration imports of the form "from <module> import *", and those<br>
will blow up anyway since zero doesn't have __dict__ or __all__<br>
attributes.<br></blockquote><div><br></div><div>Nick's right; 0 fails on an import * to pull anything in of interest. And as I said on python-checkins -- you can ignore that email, Alexander -- there is a historical reason because in Python 2 if you tried an implicit relative import a value of None met to do an absolute import. This doesn't have that effect in py3k as explicit relative imports are the only way to do relative imports (and luckily importlib does the proper thing for this as well =).</div>
</div>