Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To answer your questions:</p> <h3><code>main()</code> function</h3> <p>Nothing is special about it. You have to call it yourself, by doing something like:</p> <pre><code>def main(): print "This is main" if __name__ == "__main__": main() </code></pre> <h3>Why use <code>main()</code></h3> <p>The reason you might do that is to keep your main entry-point code together in a convenient way. For instance, if you create some variables in <code>main()</code>, they won't be global variables, which avoids polluting the global namespace. It also prevents the <code>main()</code> function from being run if you import the module from another (instead of running it directly as a script). This can be useful if you don't want to do some initialization (e.g., print messages) when importing, but you do want to do them when running as a standalone script.</p> <h3>How does Python decide which function to call</h3> <p>Python does not support "overloading" in this sense. There can only be one function with a given name in a given namespace. If you make a second function with the same name (or second method with the same name in the same class), you overwrite the first one completely.</p> <h3><code>__init__.py</code></h3> <p>This question is not really related to your others. But no, it doesn't process them in a different way. It processes them at a different time (when you import a package, rather than a module in a package), but the code in them is run just the same as the code in any other Python file.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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