[Tutor] Question on "import foobar" vs "from foobar import *"

Rob Cherry pythontutor at lxrb.com
Fri Jan 8 20:21:50 CET 2010


Still trying to get the hang of some python intricacies, but this one
has come up a few times.  Beyond the obvious syntactic niceties what
is the difference between importing with and without the "from"
syntax?

Its nice for example to do this -

from socket import *
googleip = gethostbyname("www.google.com")

vs

import socket
googleip = socket.gethostbyname("www.google.com")

Is there any difference between these concepts?  Is there an easy
google search term for me to research the difference to death?

Thanks in advance!

Rob


More information about the Tutor mailing list