Where and when does Python say this to you?

Peter Otten __peter__ at web.de
Tue Feb 8 14:38:01 CET 2011


gracemia gracemia 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 the variable names with the module name:

import socket
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)

Have you worked through the tutorial 

http://docs.python.org/tutorial/index.html

already?



More information about the Python-list mailing list