Where and when does Python say this to you?

gracemia gracemia at gmail.com
Tue Feb 8 15:08:57 CET 2011


On 8 feb, 14:40, Chris Rebert <c... at rebertia.com> wrote:
> On Tue, Feb 8, 2011 at 5:26 AM, gracemia gracemia <grace... 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; it only imports
> the name of the module itself. Thus:
>
> import socket
> sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
>
> I would recommend (re-)reading the relevant part of the tutorial:http://docs.python.org/tutorial/modules.html
>
> Cheers,
> Chris
> --
> I would also recommend bypassing the EggHeadCafe junk and instead
> posting directly to the newsgroup/mailinglist.http://blog.rebertia.com

Sorry about my reply numbers, my browser blocked.

Thank you very much. It works for me.




More information about the Python-list mailing list