This imports the function / class / module _ into the current namespace. So instead of typing GTG._ , you just need to type _ to use it.
Here are some documents:
http://docs.python.org/tutorial/modules.html#more-on-modules
It should be noted that you should use this with caution. Doing this too much can pollute the current namespace, make the code more difficult to read, and possibly introduce runtime errors. Also, NEVER NEVER do this:
from MODULE import *
as it is heavily polluting the current namespace.
This method is most useful when you know that you are only going to use one or two functions / classes / modules from a module, since it only imports the listed assets.
For example, if I want to use the imap function from the itertools module, and I know that I will not need other itertools functions, I could write
from itertools import imap
and it will only import the imap function.
As I said earlier, this should be used with caution, as some people might think that
import itertools
more readable than
from itertools import imap
since it accurately determines which module the imap function came from.
Paul woolcock
source share