Where and when does Python say this to you?

Benjamin Kaplan benjamin.kaplan at case.edu
Tue Feb 8 14:39:22 CET 2011

On Tue, Feb 8, 2011 at 8:27 AM, gracemia gracemia <gracemia at gmail.com> wrote:
> This is the simple code:
> ----------------------------------------
> import socket
> sock = socket(AF_UNIX, SOCK_STREAM)
> ------------------------------------------
> Thank you

I think you're having a bit of trouble with Python's namespaces. doing
"import socket" does not give you all of the socket module's stuff in
your current namespace. For that, you do "from socket import *", but
that's bad form because you can end up clobbering a lot of stuff.
There's two ways to do it:

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

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

> Submitted via EggHeadCafe
> SQL Server CLR Stored Procedures for External Access
> http://www.eggheadcafe.com/tutorials/aspnet/08c40d08-af4a-41f6-9352-91ac82b90078/sql-server-clr-stored-procedures-for-external-access.aspx
> --
> http://mail.python.org/mailman/listinfo/python-list

More information about the Python-list mailing list