Hi,
A common question we get in the #python IRC channel is, "I tried
importing a module, but I get an AttributeError trying to use the things
it said it provided." Turns out the beginner named their own file the
same as the module they were trying to use.
That is, they want to try (for example) the "azure" package. So they
make a file called azure.py, and start with "import azure". The import
succeeds, but it has none of the contents the documentation claims,
because they have …
[View More]imported themselves. It's baffling, because they have
used the exact statements shown in the examples, but it doesn't work.
Could we make this a more obvious failure? Is there ever a valid reason
for a file to import itself? Is this situation detectable in the import
machinery?
--Ned.
[View Less]