Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I still cannot tell what you are trying to do or even asking, but this is my best guess:</p> <p>Normally, just use classic imports.</p> <p><strong>IF</strong> a module is growing too large, or if you have an extremely good reason to split things up but desire to share the same namespace, you can "hoist" values into a dummy namespace. For example if I had <code>widget.Foo</code> and <code>widget.Bar</code> and wanted them in different files, but I wanted to be able to type <code>Foo</code> and <code>Bar</code> in each file, I would normally have to <code>from widget import Foo</code> and <code>from widget import Bar</code>. If you have MANY of these files (foo.py,bar.py,baz.py,...,zeta.py) it can get a bit unwieldy. Thus you can improve your situation by importing them only once, in <code>widget/__init__.py</code>, and then going <code>from foo import *, from bar import *, ...</code> in each folder just <strong>once</strong>, and going <code>from widget import *</code> only once in each module. And you're done!... well... almost...</p> <p>This gets you into a circular import scenario, which you have to be extremely careful of: <a href="https://stackoverflow.com/questions/744373/python-circular-or-cyclic-imports">Circular (or cyclic) imports in Python</a> It will be fine for example if you reference <code>Bar</code> in a function in <code>foo.py</code>, everything is fine because you don't immediately use the value. However if you do <code>x = Bar</code> in <code>foo.py</code> then the value may not have been defined yet!</p> <p>sidenote: You can programatically import using the <code>__import__</code> function. If you couple this with <code>os.walk</code> then you can avoid having to type <code>from ... import *</code> for each file in your widget folder. This is a critical and necessary step to avoid bugs down the line.</p>
    singulars
    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. 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.
    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