Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This imports the function/class/module <code>_</code> into the current namespace. So instead of having to type <code>GTG._</code>, you just have to type <code>_</code> to use it.</p> <p>Here is some documentation:</p> <p><a href="http://docs.python.org/tutorial/modules.html#more-on-modules" rel="nofollow noreferrer">http://docs.python.org/tutorial/modules.html#more-on-modules</a></p> <p>It should be noted that you should use this with care. Doing this too much could pollute the current namespace, making code harder to read, and possibly introducing runtime errors. Also, NEVER NEVER NEVER do this:</p> <pre><code>from MODULE import * </code></pre> <p>, as it very much pollutes the current namespace.</p> <p>This technique is most useful when you know you are only going to use one or two functions/classes/modules from a module, since doing this only imports the listed assets.</p> <p>For example, if I want to use the <code>imap</code> function from the <code>itertools</code> module, and I know I won't need any other <code>itertools</code> functions, I could write</p> <pre><code>from itertools import imap </code></pre> <p>and it would only import the <code>imap</code> function. </p> <p>Like I said earlier, this should be used with care, since some people may think that</p> <pre><code>import itertools # ... more code ... new_list = itertools.imap(my_func, my_list) </code></pre> <p>is more readable than</p> <pre><code>from itertools import imap # ... more code ... new_list = imap(my_func, my_list) </code></pre> <p>as it makes it clear exactly which module the <code>imap</code> function came from.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload