Where and when does Python say this to you?

Grant Edwards invalid at invalid.invalid
Tue Feb 8 09:54:20 EST 2011


On 2011-02-08, Chris Rebert <clp2 at rebertia.com> wrote:
> On Tue, Feb 8, 2011 at 5:26 AM, gracemia gracemia <gracemia at gmail.com> wrote:
>> ??File "prueba.py", line 4, in <module>
>> ?? ??sock = socket(AF_UNIX, SOCK_STREAM)
>> NameError: name 'AF_UNIX' is not defined
>>
>> code:
>>
>> import socket
>> sock = socket(AF_UNIX, SOCK_STREAM)
>
> You need to qualify all those names. Normal `import` doesn't dump all
> the importee's names into the importer's namespace;

Unfortunately, it's somewhat common for example code in various places
to show the above usage (where somebody did a "from <whatever> import
*).  IIRC there used to be examples like that even in the official
docs, but I haven't seen any there in a while.

But examples that look like that are still pretty easy to stumble
across using Google.

I'm guessing he copied the code from a "tutorial" example like this:

http://www.evolt.org/node/60276

-- 
Grant Edwards               grant.b.edwards        Yow! hubub, hubub, HUBUB,
                                  at               hubub, hubub, hubub, HUBUB,
                              gmail.com            hubub, hubub, hubub.



More information about the Python-list mailing list